]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
counters: work around unix-socket init issues
authorVictor Julien <victor@inliniac.net>
Wed, 27 May 2015 09:33:41 +0000 (11:33 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 27 May 2015 12:21:37 +0000 (14:21 +0200)
src/app-layer-dns-udp.c
src/app-layer-htp.c
src/app-layer.c
src/app-layer.h
src/runmode-unix-socket.c
src/suricata.c

index 3e533ba75ff20a739e35c246ecdece1c186e6f3f..eb87849c5211d10df3b39cf38ba13888ba6fc5a1 100644 (file)
@@ -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);
index fc8c564ced802e7681fadc81aab6817ce8e01df4..dd4797572e9f936d4316443e2be22b2683526e90 100644 (file)
@@ -2547,9 +2547,6 @@ void HTPConfigure(void)
         HTPConfigSetDefaultsPhase2(s->name, htprec);
     }
 
-    StatsRegisterGlobalCounter("http.memuse", HTPMemuseGlobalCounter);
-    StatsRegisterGlobalCounter("http.memcap", HTPMemcapGlobalCounter);
-
     SCReturn;
 }
 
index 0e6818fd00064c223b85585053dfd994ce991080..c47c2dd6624afedd2f5cd5582cecd7a34f6257fa 100644 (file)
@@ -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
index ca221d2dc1d8ba1604d3396793b829c59fdf91ac..f45afe6798c7fcdbc83a16051fd741741b9695c6 100644 (file)
@@ -130,6 +130,7 @@ static inline void AppLayerProfilingStore(AppLayerThreadCtx *app_tctx, Packet *p
 #endif
 }
 
+void AppLayerRegisterGlobalCounters(void);
 
 /***** Unittests *****/
 
index 6657d7e91d4fa5836ef46cd5d0860cf0fbad9b63..bc7f24cc70dc69f5a7d340dc248a7c3f4fae4d13 100644 (file)
@@ -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);
index ab65ed92a30d3387e3e8f7581357621cbf11158d..4b88b7b12ab08260fb7f4651c62a0417fcb8b239 100644 (file)
@@ -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)