From 567ef8f5f494b5c03d29cc6cfaf833aeabb07b89 Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Fri, 14 Oct 2011 19:43:10 +0530 Subject: [PATCH] update broken stats.log. Use pktacqloop funcs in pcap-file, pfring, pcap-live, af-pkt to sync counters - bug #343 --- src/counters.c | 9 +++++---- src/source-af-packet.c | 4 ++++ src/source-pcap-file.c | 3 +++ src/source-pcap.c | 4 ++++ src/source-pfring.c | 4 ++++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/counters.c b/src/counters.c index 40436c2..defc67d 100644 --- a/src/counters.c +++ b/src/counters.c @@ -520,18 +520,19 @@ static void *SCPerfWakeupThread(void *arg) tv = tv_root[TVT_PPT]; while (tv != NULL) { - if (tv->inq == NULL || tv->sc_perf_pctx.head == NULL) { + if (tv->sc_perf_pctx.head == NULL) { tv = tv->next; continue; } - q = &trans_q[tv->inq->id]; - /* assuming the assignment of an int to be atomic, and even if it's * not, it should be okay */ tv->sc_perf_pctx.perf_flag = 1; - SCCondSignal(&q->cond_q); + if (tv->inq != NULL) { + q = &trans_q[tv->inq->id]; + SCCondSignal(&q->cond_q); + } tv = tv->next; } diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 479cdbf..6af2951 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -390,6 +390,10 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot) ptv->afp_state = AFP_STATE_DOWN; continue; } + + if (tv->sc_perf_pctx.perf_flag == 1) { + SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0); + } } if (suricata_ctl_flags & SURICATA_STOP || diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index 5d78b2a..b814144 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -183,6 +183,9 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot) { EngineStop(); break; } + if (tv->sc_perf_pctx.perf_flag == 1) { + SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0); + } } SCReturnInt(TM_ECODE_OK); diff --git a/src/source-pcap.c b/src/source-pcap.c index e53ca88..82e5cb9 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -264,6 +264,10 @@ TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot) break; } } + + if (tv->sc_perf_pctx.perf_flag == 1) { + SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0); + } } SCReturnInt(TM_ECODE_OK); diff --git a/src/source-pfring.c b/src/source-pfring.c index 78a8268..bd18fe9 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -249,6 +249,10 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot) TmqhOutputPacketpool(ptv->tv, p); return TM_ECODE_FAILED; } + + if (tv->sc_perf_pctx.perf_flag == 1) { + SCPerfUpdateCounterArray(tv->sc_perf_pca, &tv->sc_perf_pctx, 0); + } } return TM_ECODE_OK; -- 1.7.1