diff options
author | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2008-01-14 15:22:24 +0000 |
---|---|---|
committer | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2008-01-14 15:22:24 +0000 |
commit | 6e5b6c91625fd431ac3d1339f55a4aa278ff2604 (patch) | |
tree | 79e087eebf878ff86bc4dd74292c97748f593b15 /src/run.c | |
parent | 94aa8b70f2e8cf7cf664d7c0e86a9ebc287010ef (diff) | |
download | conntrack-tools-6e5b6c91625fd431ac3d1339f55a4aa278ff2604.tar.gz conntrack-tools-6e5b6c91625fd431ac3d1339f55a4aa278ff2604.zip |
improve alarm framework based on suggestions from Max Duempel
Diffstat (limited to 'src/run.c')
-rw-r--r-- | src/run.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -224,19 +224,20 @@ static int __run(struct timeval *next_alarm) void run(void) { - struct timeval next_alarm = { - .tv_sec = 1, - .tv_usec = 0 - }; + struct timeval next_alarm; struct timeval *next = &next_alarm; + struct timeval tv; - if (CONFIG(flags) & CTD_STATS_MODE) - next = NULL; + /* initialization: get the first alarm available */ + gettimeofday(&tv, NULL); + get_next_alarm(&tv, next); while(1) { if (__run(next)) { sigprocmask(SIG_BLOCK, &STATE(block), NULL); - do_alarm_run(next); + next = &next_alarm; + if (!do_alarm_run(next)) + next = NULL; /* no next alarms */ sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); } } |