From 920b90f2b03c60b6940e83cdce8c4b4bfbbc4268 Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Wed, 9 Jan 2008 22:52:31 +0000 Subject: wake up the daemon iff there are real events to handle instead of polling (Based on comments from Max Kellerman) --- src/cache_timer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cache_timer.c') diff --git a/src/cache_timer.c b/src/cache_timer.c index f3940f3..c0075f5 100644 --- a/src/cache_timer.c +++ b/src/cache_timer.c @@ -17,6 +17,7 @@ */ #include +#include #include "conntrackd.h" #include "us-conntrack.h" #include "cache.h" @@ -35,7 +36,7 @@ static void timer_add(struct us_conntrack *u, void *data) struct alarm_list *alarm = data; init_alarm(alarm); - set_alarm_expiration(alarm, CONFIG(cache_timeout)); + set_alarm_expiration_secs(alarm, CONFIG(cache_timeout)); set_alarm_data(alarm, u); set_alarm_function(alarm, timeout); add_alarm(alarm); @@ -55,12 +56,15 @@ static void timer_destroy(struct us_conntrack *u, void *data) static int timer_dump(struct us_conntrack *u, void *data, char *buf, int type) { + struct timeval tv, tmp; struct alarm_list *alarm = data; if (type == NFCT_O_XML) return 0; - return sprintf(buf, " [expires in %ds]", alarm->expires); + gettimeofday(&tv, NULL); + timersub(&tv, &alarm->tv, &tmp); + return sprintf(buf, " [expires in %ds]", tmp.tv_sec); } struct cache_feature timer_feature = { -- cgit v1.2.3