summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-03-21 08:31:35 +0000
committerpjd <pjd@FreeBSD.org>2011-03-21 08:31:35 +0000
commit102418c6cd4112e26606b49157d678ce4b68aad3 (patch)
treed4ba07d77965e818f182e8d17aa949c73b19a7b5 /sbin
parent33a58e7972e806cb54eb168af23eed66cb3753dd (diff)
downloadFreeBSD-src-102418c6cd4112e26606b49157d678ce4b68aad3.zip
FreeBSD-src-102418c6cd4112e26606b49157d678ce4b68aad3.tar.gz
If there is any traffic on one of out descriptors, we were not checking for
long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. MFC after: 1 week
Diffstat (limited to 'sbin')
-rw-r--r--sbin/hastd/hastd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c
index dd53eff..4688ed5 100644
--- a/sbin/hastd/hastd.c
+++ b/sbin/hastd/hastd.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
+#include <time.h>
#include <unistd.h>
#include <activemap.h>
@@ -877,9 +878,11 @@ main_loop(void)
struct timeval seltimeout;
struct timespec sigtimeout;
int fd, maxfd, ret, signo;
+ time_t lastcheck, now;
sigset_t mask;
fd_set rfds;
+ lastcheck = time(NULL);
seltimeout.tv_sec = REPORT_INTERVAL;
seltimeout.tv_usec = 0;
sigtimeout.tv_sec = 0;
@@ -943,9 +946,18 @@ main_loop(void)
PJDLOG_ASSERT(maxfd + 1 <= (int)FD_SETSIZE);
ret = select(maxfd + 1, &rfds, NULL, NULL, &seltimeout);
- if (ret == 0)
+ now = time(NULL);
+ if (lastcheck + REPORT_INTERVAL <= now) {
hook_check();
- else if (ret == -1) {
+ lastcheck = now;
+ }
+ if (ret == 0) {
+ /*
+ * select(2) timed out, so there should be no
+ * descriptors to check.
+ */
+ continue;
+ } else if (ret == -1) {
if (errno == EINTR)
continue;
KEEP_ERRNO((void)pidfile_remove(pfh));
OpenPOWER on IntegriCloud