+
unsigned int
auth_reload()
{
@@ -91,8 +93,14 @@ auth_reload()
int fd;
if ((fd = open(etab.statefn, O_RDONLY)) < 0) {
- xlog(L_FATAL, "couldn't open %s", etab.statefn);
- } else if (fstat(fd, &stb) < 0) {
+ if (errno != EMFILE && errno != ENFILE)
+ xlog(L_FATAL, "couldn't open %s", etab.statefn);
+ /* remove idle */
+ __svc_destroy_idle(5, FALSE);
+ if ((fd = open(etab.statefn, O_RDONLY)) < 0)
+ xlog(L_FATAL, "couldn't open %s", etab.statefn);
+ }
+ if (fstat(fd, &stb) < 0) {
xlog(L_FATAL, "couldn't stat %s", etab.statefn);
close(fd);
} else if (last_fd != -1 && stb.st_ino == last_inode) {
diff --git a/utils/mountd/svc_run.c b/utils/mountd/svc_run.c
index 167b9757bde2..ada8d0ac8844 100644
--- a/utils/mountd/svc_run.c
+++ b/utils/mountd/svc_run.c
@@ -59,6 +59,7 @@
#include "export.h"
void my_svc_run(void);
+extern void __svc_destroy_idle(int , bool_t);
#if defined(__GLIBC__) && LONG_MAX != INT_MAX
/* bug in glibc 2.3.6 and earlier, we need
@@ -95,6 +96,7 @@ my_svc_run(void)
{
fd_set readfds;
int selret;
+ struct timeval tv;
for (;;) {
@@ -102,8 +104,10 @@ my_svc_run(void)
cache_set_fds(&readfds);
v4clients_set_fds(&readfds);
+ tv.tv_sec = 30;
+ tv.tv_usec = 0;
selret = select(FD_SETSIZE, &readfds,
- (void *) 0, (void *) 0, (struct timeval *) 0);
+ (void *) 0, (void *) 0, &tv);
switch (selret) {
@@ -113,7 +117,9 @@ my_svc_run(void)
continue;
xlog(L_ERROR, "my_svc_run() - select: %m");
return;
-
+ case 0:
+ __svc_destroy_idle(30, FALSE);
+ continue;
default:
selret -= cache_process_req(&readfds);
selret -= v4clients_process(&readfds);
diff --git a/utils/statd/svc_run.c b/utils/statd/svc_run.c
index e343c7689860..8888788c81d0 100644
--- a/utils/statd/svc_run.c
+++ b/utils/statd/svc_run.c
@@ -59,6 +59,7 @@
void my_svc_exit(void);
static int svc_stop = 0;
+extern void __svc_destroy_idle(int , bool_t);
/*
* This is the global notify list onto which all SM_NOTIFY and
CALLBACK
@@ -85,6 +86,7 @@ my_svc_run(int sockfd)
FD_SET_TYPE readfds;
int selret;
time_t now;
+ struct timeval tv;
svc_stop = 0;
@@ -101,7 +103,6 @@ my_svc_run(int sockfd)
/* Set notify sockfd for waiting for reply */
FD_SET(sockfd, &readfds);
if (notify) {
- struct timeval tv;
tv.tv_sec = NL_WHEN(notify) - now;
tv.tv_usec = 0;
@@ -111,8 +112,10 @@ my_svc_run(int sockfd)
(void *) 0, (void *) 0, &tv);
} else {
xlog(D_GENERAL, "Waiting for client connections");
+ tv.tv_sec = 30;
+ tv.tv_usec = 0;
selret = select(FD_SETSIZE, &readfds,
- (void *) 0, (void *) 0, (struct timeval *) 0);
+ (void *) 0, (void *) 0, &tv);
}
switch (selret) {
@@ -124,7 +127,9 @@ my_svc_run(int sockfd)
return;
case 0:
- /* A notify/callback timed out. */
+ /* A notify/callback/wait for client timed out. */
+ if (!notify)
+ __svc_destroy_idle(30, FALSE);
continue;
default: