]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Update pcap-file runmode to adhere to new thread standard.
authorZachary Rasmor <zachary.r.rasmor@lmco.com>
Thu, 5 Nov 2015 04:43:31 +0000 (23:43 -0500)
committerVictor Julien <victor@inliniac.net>
Mon, 2 May 2016 08:10:40 +0000 (10:10 +0200)
src/runmode-pcap-file.c

index eede9f4d11dcd261d9251c38449af2bd43f1e0e7..fdd0fe077c5be4efc5a7dc7d687269810f470d29 100644 (file)
@@ -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",