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-09 22:52:31 +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-09 22:52:31 +0000 |
commit | 920b90f2b03c60b6940e83cdce8c4b4bfbbc4268 (patch) | |
tree | 1dc9fe70ee9304ea0ca72ceb6a2a07537d302cb8 /src/sync-alarm.c | |
parent | 6023de67c84e531939b77454783835c65f694bff (diff) | |
download | conntrack-tools-920b90f2b03c60b6940e83cdce8c4b4bfbbc4268.tar.gz conntrack-tools-920b90f2b03c60b6940e83cdce8c4b4bfbbc4268.zip |
wake up the daemon iff there are real events to handle instead of polling (Based on comments from Max Kellerman)
Diffstat (limited to 'src/sync-alarm.c')
-rw-r--r-- | src/sync-alarm.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sync-alarm.c b/src/sync-alarm.c index a0791ac..632eff2 100644 --- a/src/sync-alarm.c +++ b/src/sync-alarm.c @@ -30,7 +30,14 @@ static void refresher(struct alarm_list *a, void *data) debug_ct(u->ct, "persistence update"); - a->expires = random() % CONFIG(refresh) + 1; + init_alarm(a); + set_alarm_expiration_secs(a, random() % CONFIG(refresh) + 1); + set_alarm_expiration_usecs(a, random() % 999999 + 1); + + set_alarm_data(a, u); + set_alarm_function(a, refresher); + add_alarm(a); + net = BUILD_NETMSG(u->ct, NFCT_Q_UPDATE); len = prepare_send_netmsg(STATE_SYNC(mcast_client), net); mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len); @@ -41,7 +48,8 @@ static void cache_alarm_add(struct us_conntrack *u, void *data) struct alarm_list *alarm = data; init_alarm(alarm); - set_alarm_expiration(alarm, (random() % conf.refresh) + 1); + set_alarm_expiration_secs(alarm, random() % CONFIG(refresh) + 1); + set_alarm_expiration_usecs(alarm, random() % 999999 + 1); set_alarm_data(alarm, u); set_alarm_function(alarm, refresher); add_alarm(alarm); @@ -50,7 +58,7 @@ static void cache_alarm_add(struct us_conntrack *u, void *data) static void cache_alarm_update(struct us_conntrack *u, void *data) { struct alarm_list *alarm = data; - mod_alarm(alarm, (random() % conf.refresh) + 1); + mod_alarm(alarm, random() % CONFIG(refresh) + 1, random() % 999999 + 1); } static void cache_alarm_destroy(struct us_conntrack *u, void *data) |