pcap: clean up decode thread local storage

Clean up the thread local data the decode portion of pcap uses.

Bug #978
pull/914/merge
Victor Julien 11 years ago
parent 900fc6fdc7
commit c3e193e786

@ -113,6 +113,7 @@ TmEcode ReceivePcapThreadDeinit(ThreadVars *, void *);
TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot); TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot);
TmEcode DecodePcapThreadInit(ThreadVars *, void *, void **); TmEcode DecodePcapThreadInit(ThreadVars *, void *, void **);
TmEcode DecodePcapThreadDeinit(ThreadVars *tv, void *data);
TmEcode DecodePcap(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); TmEcode DecodePcap(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
/** protect pcap_compile and pcap_setfilter, as they are not thread safe: /** 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].ThreadInit = DecodePcapThreadInit;
tmm_modules[TMM_DECODEPCAP].Func = DecodePcap; tmm_modules[TMM_DECODEPCAP].Func = DecodePcap;
tmm_modules[TMM_DECODEPCAP].ThreadExitPrintStats = NULL; 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].RegisterTests = NULL;
tmm_modules[TMM_DECODEPCAP].cap_flags = 0; tmm_modules[TMM_DECODEPCAP].cap_flags = 0;
tmm_modules[TMM_DECODEPCAP].flags = TM_FLAG_DECODE_TM; 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); 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) void PcapTranslateIPToDevice(char *pcap_dev, size_t len)
{ {
char errbuf[PCAP_ERRBUF_SIZE]; char errbuf[PCAP_ERRBUF_SIZE];

Loading…
Cancel
Save