summaryrefslogtreecommitdiff
path: root/src/stats-mode.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-05 16:41:15 +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-05 16:41:15 +0000
commit1102a95296e39f671efe51bb6bd9b30e5c14c91e (patch)
treed1d42347ea82ce0075884acc23ffa7ba932fb3a1 /src/stats-mode.c
parent1c0b4d3721e40586219fb7676e61e6ba19affdd2 (diff)
downloadconntrack-tools-1102a95296e39f671efe51bb6bd9b30e5c14c91e.tar.gz
conntrack-tools-1102a95296e39f671efe51bb6bd9b30e5c14c91e.zip
implement buffered connection logging to improve performance
Diffstat (limited to 'src/stats-mode.c')
-rw-r--r--src/stats-mode.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/stats-mode.c b/src/stats-mode.c
index e817c4e..05a1b2c 100644
--- a/src/stats-mode.c
+++ b/src/stats-mode.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include "cache.h"
+#include "log.h"
#include "conntrackd.h"
#include <libnfnetlink/libnfnetlink.h>
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
@@ -37,6 +38,12 @@ static int init_stats(void)
}
memset(state.stats, 0, sizeof(struct ct_stats_state));
+ STATE_STATS(buffer_log) = buffer_create(CONFIG(stats).buffer_size);
+ if (!STATE_STATS(buffer_log)) {
+ dlog(STATE(log), LOG_ERR, "can't allocate stats buffer");
+ return -1;
+ }
+
STATE_STATS(cache) = cache_create("stats",
LIFETIME,
CONFIG(family),
@@ -53,6 +60,9 @@ static int init_stats(void)
static void kill_stats()
{
cache_destroy(STATE_STATS(cache));
+ buffer_flush(STATE_STATS(buffer_log),
+ dlog_buffered_ct_flush,
+ STATE(stats_log));
}
/* handler for requests coming via UNIX socket */
@@ -172,7 +182,7 @@ static int event_destroy_stats(struct nf_conntrack *ct)
if (cache_del(STATE_STATS(cache), ct)) {
debug_ct(ct, "cache destroy");
- dlog_ct(STATE(stats_log), ct);
+ dlog_buffered_ct(STATE(stats_log), STATE_STATS(buffer_log), ct);
return 1;
} else {
debug_ct(ct, "can't destroy!");