pcap-file: don't kill engine in unix socket mode

This patch updates the cleaning code to avoid to exit from suricata
in unix socket mode when a invalid pcap is given.
pull/260/head
Eric Leblond 12 years ago
parent bc04090bc9
commit 6b81430bcb

@ -182,10 +182,16 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
if (unlikely(r == -1)) {
SCLogError(SC_ERR_PCAP_DISPATCH, "error code %" PRId32 " %s",
r, pcap_geterr(pcap_g.pcap_handle));
if (! RunModeUnixSocketIsActive()) {
/* in the error state we just kill the engine */
EngineKill();
SCReturnInt(TM_ECODE_FAILED);
} else {
pcap_close(pcap_g.pcap_handle);
pcap_g.pcap_handle = NULL;
UnixSocketPcapFile(TM_ECODE_DONE);
SCReturnInt(TM_ECODE_DONE);
}
} else if (unlikely(r == 0)) {
SCLogInfo("pcap file end of file reached (pcap err code %" PRId32 ")", r);
if (! RunModeUnixSocketIsActive()) {
@ -199,8 +205,15 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
break;
} else if (ptv->cb_result == TM_ECODE_FAILED) {
SCLogError(SC_ERR_PCAP_DISPATCH, "Pcap callback PcapFileCallbackLoop failed");
if (! RunModeUnixSocketIsActive()) {
EngineKill();
SCReturnInt(TM_ECODE_FAILED);
} else {
pcap_close(pcap_g.pcap_handle);
pcap_g.pcap_handle = NULL;
UnixSocketPcapFile(TM_ECODE_DONE);
SCReturnInt(TM_ECODE_DONE);
}
}
SCPerfSyncCountersIfSignalled(tv, 0);
}

Loading…
Cancel
Save