summaryrefslogtreecommitdiff
path: root/src/alarm.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>2007-07-09 19:11:53 +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>2007-07-09 19:11:53 +0000
commit96084e1a1f2e0a49c961bbddb9fffd2e03bfae3f (patch)
treec078d88b157faa7c5ce76bc4591205756f09742b /src/alarm.c
parent4df0be6fbf6a47905e0edf11c13b49ea0eacee5b (diff)
downloadconntrack-tools-96084e1a1f2e0a49c961bbddb9fffd2e03bfae3f.tar.gz
conntrack-tools-96084e1a1f2e0a49c961bbddb9fffd2e03bfae3f.zip
- conntrack-tools requires libnetfilter_conntrack >= 0.0.81
- add len field to nethdr - implement buffered send/recv to batch messages - stop using netlink format for network messages: use similar TLV-based format - reduce synchronization messages size up to 60% - introduce periodic alive messages for sync-nack protocol - timeslice alarm implementation: remove alarm pthread, remove locking - simplify debugging functions: use nfct_snprintf instead - remove major use of libnfnetlink functions: use libnetfilter_conntrack API - deprecate conntrackd -F, use conntrack -F instead - major rework of the network infrastructure: much simple, less messy
Diffstat (limited to 'src/alarm.c')
-rw-r--r--src/alarm.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/src/alarm.c b/src/alarm.c
index 1a465c2..b4db167 100644
--- a/src/alarm.c
+++ b/src/alarm.c
@@ -22,17 +22,13 @@
#include "conntrackd.h"
#include "alarm.h"
#include "jhash.h"
-#include <pthread.h>
#include <time.h>
#include <errno.h>
/* alarm cascade */
-#define ALARM_CASCADE_SIZE 10
+#define ALARM_CASCADE_SIZE STEPS_PER_SECONDS
static struct list_head *alarm_cascade;
-/* thread stuff */
-static pthread_t alarm_thread;
-
struct alarm_list *create_alarm()
{
return (struct alarm_list *) malloc(sizeof(struct alarm_list));
@@ -86,24 +82,11 @@ int mod_alarm(struct alarm_list *alarm, unsigned long expires)
return 0;
}
-void __run_alarms()
+void do_alarm_run(int step)
{
struct list_head *i, *tmp;
struct alarm_list *t;
- struct timespec req = {0, 1000000000 / ALARM_CASCADE_SIZE};
- struct timespec rem;
- static int step = 0;
-
-retry:
- if (nanosleep(&req, &rem) == -1) {
- /* interrupted syscall: retry with remaining time */
- if (errno == EINTR) {
- memcpy(&req, &rem, sizeof(struct timespec));
- goto retry;
- }
- }
- lock();
list_for_each_safe(i, tmp, &alarm_cascade[step]) {
t = (struct alarm_list *) i;
@@ -111,17 +94,9 @@ retry:
if (t->expires == 0)
t->function(t, t->data);
}
- step = (step + 1) < ALARM_CASCADE_SIZE ? step + 1 : 0;
- unlock();
-}
-
-void *run_alarms(void *foo)
-{
- while(1)
- __run_alarms();
}
-int create_alarm_thread()
+int init_alarm_scheduler()
{
int i;
@@ -132,10 +107,10 @@ int create_alarm_thread()
for (i=0; i<ALARM_CASCADE_SIZE; i++)
INIT_LIST_HEAD(&alarm_cascade[i]);
- return pthread_create(&alarm_thread, NULL, run_alarms, NULL);
+ return 0;
}
-int destroy_alarm_thread()
+void destroy_alarm_scheduler()
{
- return pthread_cancel(alarm_thread);
+ free(alarm_cascade);
}