]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threading: remove 'trans_q' array of packet queues
authorVictor Julien <victor@inliniac.net>
Wed, 13 Nov 2019 15:29:11 +0000 (16:29 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 7 Feb 2020 14:43:10 +0000 (15:43 +0100)
Let the queues code set up PacketQueues on demand.

src/suricata.c
src/suricata.h
src/tm-queues.c

index 14b15403b1a22b45963a7e53918f70adec567d36..477eddd83a2f623784d6779539b5f1ac8631ca05 100644 (file)
@@ -328,21 +328,6 @@ uint8_t print_mem_flag = 1;
 
 void GlobalsInitPreConfig(void)
 {
-    memset(trans_q, 0, sizeof(trans_q));
-
-    /* Initialize the trans_q mutex */
-    int blah;
-    int r = 0;
-    for(blah=0;blah<256;blah++) {
-        r |= SCMutexInit(&trans_q[blah].mutex_q, NULL);
-        r |= SCCondInit(&trans_q[blah].cond_q, NULL);
-   }
-
-    if (r != 0) {
-        SCLogInfo("Trans_Q Mutex not initialized correctly");
-        exit(EXIT_FAILURE);
-    }
-
     TimeInit();
     SupportFastPatternForSigMatchTypes();
     SCThresholdConfGlobalInit();
index a05febdb523c51f3799b4e24f98a6ea7d54273cf..a15b20a2c212607c704024a7bf7e5c4150f9e6b2 100644 (file)
@@ -125,11 +125,6 @@ enum {
 
 #include "runmodes.h"
 
-/* queue's between various other threads
- * XXX move to the TmQueue structure later
- */
-PacketQueue trans_q[256];
-
 typedef struct SCInstance_ {
     enum RunModes run_mode;
     enum RunModes aux_run_mode;
index 1d1e1ccff1869dc9210838471de2190a8bd1b2a8..13943ae7e03eb3be90973e12f6c008c7edd87f82 100644 (file)
@@ -46,13 +46,15 @@ Tmq *TmqCreateQueue(const char *name)
     q->id = tmq_id++;
     q->is_packet_pool = (strcmp(q->name, "packetpool") == 0);
 
-    q->pq = &trans_q[q->id];
+    q->pq = PacketQueueAlloc();
+    if (q->pq == NULL)
+        goto error;
 
     SCLogDebug("created queue \'%s\', %p", name, q);
     return q;
 
 error:
-    SCLogError(SC_ERR_THREAD_QUEUE, "too many thread queues %u, max is %u", tmq_id+1, TMQ_MAX_QUEUES);
+    SCLogError(SC_ERR_THREAD_QUEUE, "thread queue setup failed for '%s'", name);
     return NULL;
 }
 
@@ -81,6 +83,9 @@ void TmqResetQueues(void)
         if (tmqs[i].name) {
             SCFree(tmqs[i].name);
         }
+        if (tmqs[i].pq) {
+            PacketQueueFree(tmqs[i].pq);
+        }
     }
     memset(&tmqs, 0x00, sizeof(tmqs));
     tmq_id = 0;