summaryrefslogtreecommitdiff
path: root/src/cache_timer.c
diff options
context:
space:
mode:
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
commit920b90f2b03c60b6940e83cdce8c4b4bfbbc4268 (patch)
tree1dc9fe70ee9304ea0ca72ceb6a2a07537d302cb8 /src/cache_timer.c
parent6023de67c84e531939b77454783835c65f694bff (diff)
downloadconntrack-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/cache_timer.c')
-rw-r--r--src/cache_timer.c8
1 files changed, 6 insertions, 2 deletions
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 <stdio.h>
+#include <sys/time.h>
#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 = {