From: Zachary Rasmor Date: Thu, 5 Nov 2015 04:43:31 +0000 (-0500) Subject: Update pcap-file runmode to adhere to new thread standard. X-Git-Tag: suricata-3.1RC1~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8a40dd9068298214a065237bdf76449a06858c7;p=thirdparty%2Fsuricata.git Update pcap-file runmode to adhere to new thread standard. --- diff --git a/src/runmode-pcap-file.c b/src/runmode-pcap-file.c index eede9f4d11..fdd0fe077c 100644 --- a/src/runmode-pcap-file.c +++ b/src/runmode-pcap-file.c @@ -62,6 +62,8 @@ void RunModeFilePcapRegister(void) int RunModeFilePcapSingle(void) { char *file = NULL; + char tname[TM_THREAD_NAME_MAX]; + if (ConfGet("pcap-file.file", &file) == 0) { SCLogError(SC_ERR_RUNMODE, "Failed retrieving pcap-file from Conf"); exit(EXIT_FAILURE); @@ -72,8 +74,17 @@ int RunModeFilePcapSingle(void) PcapFileGlobalInit(); + snprintf(tname, sizeof(tname), "%s#01", thread_name_single); + + char *thread_name = SCStrdup(tname); + if (unlikely(thread_name == NULL)) + { + SCLogError(SC_ERR_RUNMODE, "failed to strdup thread name"); + exit(EXIT_FAILURE); + } + /* create the threads */ - ThreadVars *tv = TmThreadCreatePacketHandler("PcapFile", + ThreadVars *tv = TmThreadCreatePacketHandler(thread_name, "packetpool", "packetpool", "packetpool", "packetpool", "pktacqloop"); @@ -195,9 +206,17 @@ int RunModeFilePcapAutoFp(void) exit(EXIT_FAILURE); } + snprintf(tname, sizeof(tname), "%s#01", thread_name_autofp); + + char *thread_name = SCStrdup(tname); + if (unlikely(thread_name == NULL)) { + SCLogError(SC_ERR_RUNMODE, "failed to strdup thread name"); + exit(EXIT_FAILURE); + } + /* create the threads */ ThreadVars *tv_receivepcap = - TmThreadCreatePacketHandler("ReceivePcapFile", + TmThreadCreatePacketHandler(thread_name, "packetpool", "packetpool", queues, "flow", "pktacqloop"); @@ -229,11 +248,18 @@ int RunModeFilePcapAutoFp(void) } for (thread = 0; thread < thread_max; thread++) { - snprintf(tname, sizeof(tname), "Detect%d", thread+1); + snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1); snprintf(qname, sizeof(qname), "pickup%d", thread+1); SCLogDebug("tname %s, qname %s", tname, qname); + thread_name = SCStrdup(tname); + if (unlikely(thread_name == NULL)) { + SCLogError(SC_ERR_RUNMODE, "failed to strdup thread name"); + exit(EXIT_FAILURE); + } + SCLogDebug("Assigning %s affinity to cpu %u", thread_name, cpu); + ThreadVars *tv_detect_ncpu = TmThreadCreatePacketHandler(tname, qname, "flow",