]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pcap: clean up decode thread local storage
authorVictor Julien <victor@inliniac.net>
Fri, 28 Mar 2014 11:17:41 +0000 (12:17 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 2 Apr 2014 11:13:52 +0000 (13:13 +0200)
Clean up the thread local data the decode portion of pcap uses.

Bug #978

src/source-pcap.c

index a5143d9118d517a28310516dbfc266aee1af3597..81acb1f8c69e2db8699805d3beddfdf226744be7 100644 (file)
@@ -113,6 +113,7 @@ TmEcode ReceivePcapThreadDeinit(ThreadVars *, void *);
 TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot);
 
 TmEcode DecodePcapThreadInit(ThreadVars *, void *, void **);
+TmEcode DecodePcapThreadDeinit(ThreadVars *tv, void *data);
 TmEcode DecodePcap(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
 
 /** protect pcap_compile and pcap_setfilter, as they are not thread safe:
@@ -144,7 +145,7 @@ void TmModuleDecodePcapRegister (void) {
     tmm_modules[TMM_DECODEPCAP].ThreadInit = DecodePcapThreadInit;
     tmm_modules[TMM_DECODEPCAP].Func = DecodePcap;
     tmm_modules[TMM_DECODEPCAP].ThreadExitPrintStats = NULL;
-    tmm_modules[TMM_DECODEPCAP].ThreadDeinit = NULL;
+    tmm_modules[TMM_DECODEPCAP].ThreadDeinit = DecodePcapThreadDeinit;
     tmm_modules[TMM_DECODEPCAP].RegisterTests = NULL;
     tmm_modules[TMM_DECODEPCAP].cap_flags = 0;
     tmm_modules[TMM_DECODEPCAP].flags = TM_FLAG_DECODE_TM;
@@ -774,6 +775,13 @@ TmEcode DecodePcapThreadInit(ThreadVars *tv, void *initdata, void **data)
     SCReturnInt(TM_ECODE_OK);
 }
 
+TmEcode DecodePcapThreadDeinit(ThreadVars *tv, void *data)
+{
+    if (data != NULL)
+        DecodeThreadVarsFree(data);
+    SCReturnInt(TM_ECODE_OK);
+}
+
 void PcapTranslateIPToDevice(char *pcap_dev, size_t len)
 {
     char errbuf[PCAP_ERRBUF_SIZE];