From: Victor Julien Date: Wed, 13 Nov 2019 15:29:11 +0000 (+0100) Subject: threading: remove 'trans_q' array of packet queues X-Git-Tag: suricata-6.0.0-beta1~780 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e3f27a87eaae862c15316093f384db6ec9e6efa;p=thirdparty%2Fsuricata.git threading: remove 'trans_q' array of packet queues Let the queues code set up PacketQueues on demand. --- diff --git a/src/suricata.c b/src/suricata.c index 14b15403b1..477eddd83a 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -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(); diff --git a/src/suricata.h b/src/suricata.h index a05febdb52..a15b20a2c2 100644 --- a/src/suricata.h +++ b/src/suricata.h @@ -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; diff --git a/src/tm-queues.c b/src/tm-queues.c index 1d1e1ccff1..13943ae7e0 100644 --- a/src/tm-queues.c +++ b/src/tm-queues.c @@ -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;