From: Victor Julien Date: Wed, 27 May 2015 09:33:41 +0000 (+0200) Subject: counters: work around unix-socket init issues X-Git-Tag: suricata-3.0RC1~346 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb5aa8f8d5e2c348687c4756218f98b3400a76b6;p=thirdparty%2Fsuricata.git counters: work around unix-socket init issues --- diff --git a/src/app-layer-dns-udp.c b/src/app-layer-dns-udp.c index 3e533ba75f..eb87849c52 100644 --- a/src/app-layer-dns-udp.c +++ b/src/app-layer-dns-udp.c @@ -358,10 +358,6 @@ void RegisterDNSUDPParsers(void) { char *proto_name = "dns"; - StatsRegisterGlobalCounter("dns.memuse", DNSMemcapGetMemuseCounter); - StatsRegisterGlobalCounter("dns.memcap_state", DNSMemcapGetMemcapStateCounter); - StatsRegisterGlobalCounter("dns.memcap_global", DNSMemcapGetMemcapGlobalCounter); - /** DNS */ if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index fc8c564ced..dd4797572e 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2547,9 +2547,6 @@ void HTPConfigure(void) HTPConfigSetDefaultsPhase2(s->name, htprec); } - StatsRegisterGlobalCounter("http.memuse", HTPMemuseGlobalCounter); - StatsRegisterGlobalCounter("http.memcap", HTPMemcapGlobalCounter); - SCReturn; } diff --git a/src/app-layer.c b/src/app-layer.c index 0e6818fd00..c47c2dd662 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -609,6 +609,17 @@ void AppLayerProfilingStoreInternal(AppLayerThreadCtx *app_tctx, Packet *p) PACKET_PROFILING_APP_STORE(app_tctx, p); } +/** \brief HACK to work around our broken unix manager (re)init loop + */ +void AppLayerRegisterGlobalCounters(void) +{ + StatsRegisterGlobalCounter("dns.memuse", DNSMemcapGetMemuseCounter); + StatsRegisterGlobalCounter("dns.memcap_state", DNSMemcapGetMemcapStateCounter); + StatsRegisterGlobalCounter("dns.memcap_global", DNSMemcapGetMemcapGlobalCounter); + StatsRegisterGlobalCounter("http.memuse", HTPMemuseGlobalCounter); + StatsRegisterGlobalCounter("http.memcap", HTPMemcapGlobalCounter); +} + /***** Unittests *****/ #ifdef UNITTESTS diff --git a/src/app-layer.h b/src/app-layer.h index ca221d2dc1..f45afe6798 100644 --- a/src/app-layer.h +++ b/src/app-layer.h @@ -130,6 +130,7 @@ static inline void AppLayerProfilingStore(AppLayerThreadCtx *app_tctx, Packet *p #endif } +void AppLayerRegisterGlobalCounters(void); /***** Unittests *****/ diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index 6657d7e91d..bc7f24cc70 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -37,6 +37,7 @@ #include "host.h" #include "defrag.h" #include "ippair.h" +#include "app-layer.h" #include "util-profiling.h" @@ -354,6 +355,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data) FlowInitConfig(FLOW_QUIET); IPPairInitConfig(FLOW_QUIET); StreamTcpInitConfig(STREAM_VERBOSE); + AppLayerRegisterGlobalCounters(); RunModeInitializeOutputs(); StatsSetupPostConfig(); RunModeDispatch(RUNMODE_PCAP_FILE, NULL); diff --git a/src/suricata.c b/src/suricata.c index ab65ed92a3..4b88b7b12a 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2206,7 +2206,9 @@ int main(int argc, char **argv) GlobalInits(); TimeInit(); SupportFastPatternForSigMatchTypes(); - StatsInit(); + if (suri.run_mode != RUNMODE_UNIX_SOCKET) { + StatsInit(); + } if (conf_filename == NULL) conf_filename = DEFAULT_CONF_FILE; @@ -2256,6 +2258,7 @@ int main(int argc, char **argv) FlowInitConfig(FLOW_VERBOSE); StreamTcpInitConfig(STREAM_VERBOSE); IPPairInitConfig(IPPAIR_VERBOSE); + AppLayerRegisterGlobalCounters(); } if (MagicInit() != 0)