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-23 12:15:25 +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-23 12:15:25 +0000 |
commit | d658f3ed913affe96511309c6bf3d37aaec2910f (patch) | |
tree | 1d08abef62e0f7555b9198cc07597a568d36da40 | |
parent | c4d3ba8748a12a9ad466b3b1c50cc31d36cd5418 (diff) | |
download | conntrack-tools-d658f3ed913affe96511309c6bf3d37aaec2910f.tar.gz conntrack-tools-d658f3ed913affe96511309c6bf3d37aaec2910f.zip |
Max Kellermann <max@duempel.org>:
introduce alarm_pending()
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | include/alarm.h | 2 | ||||
-rw-r--r-- | src/alarm.c | 8 | ||||
-rw-r--r-- | src/cache_timer.c | 3 |
4 files changed, 14 insertions, 0 deletions
@@ -94,6 +94,7 @@ o fix error checking of local_create_server() o added struct local_server, several cleanups in local socket infrastructure o remove unused prototypes in network.h o check if the received packet is large enough +o introduce alarm_pending() version 0.9.5 (2007/07/29) ------------------------------ diff --git a/include/alarm.h b/include/alarm.h index c4ea9d7..e3e08c1 100644 --- a/include/alarm.h +++ b/include/alarm.h @@ -24,6 +24,8 @@ void add_alarm(struct alarm_list *alarm, unsigned long sc, unsigned long usc); void del_alarm(struct alarm_list *alarm); +int alarm_pending(struct alarm_list *alarm); + struct timeval * get_next_alarm_run(struct timeval *next_alarm); diff --git a/src/alarm.c b/src/alarm.c index 7352ccb..4b23bd1 100644 --- a/src/alarm.c +++ b/src/alarm.c @@ -70,6 +70,14 @@ void del_alarm(struct alarm_list *alarm) list_del_init(&alarm->head); } +int alarm_pending(struct alarm_list *alarm) +{ + if (list_empty(&alarm->head)) + return 0; + + return 1; +} + static struct timeval * calculate_next_run(struct timeval *cand, struct timeval *tv, diff --git a/src/cache_timer.c b/src/cache_timer.c index 86bb8fc..fe997ec 100644 --- a/src/cache_timer.c +++ b/src/cache_timer.c @@ -60,6 +60,9 @@ static int timer_dump(struct us_conntrack *u, void *data, char *buf, int type) if (type == NFCT_O_XML) return 0; + if (!alarm_pending(alarm)) + return 0; + gettimeofday(&tv, NULL); timersub(&tv, &alarm->tv, &tmp); return sprintf(buf, " [expires in %lds]", tmp.tv_sec); |