From: Victor Julien Date: Thu, 14 Sep 2023 04:49:31 +0000 (+0200) Subject: packetpool: signal waiter within lock X-Git-Tag: suricata-7.0.3~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc40a139acb3c66f5d34074c240a1f81dec3f002;p=thirdparty%2Fsuricata.git packetpool: signal waiter within lock Needed for predictable scheduling. From pthread_cond_signal man page: "The pthread_cond_signal() or pthread_cond_broadcast() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, if predictable scheduling behaviour is required, then that mutex is locked by the thread calling pthread_cond_signal() or pthread_cond_broadcast()." --- diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index 411af684ee..8594651795 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -193,8 +193,8 @@ void PacketPoolReturnPacket(Packet *p) my_pool->pending_tail->next = pool->return_stack.head; pool->return_stack.head = my_pool->pending_head; SC_ATOMIC_RESET(pool->return_stack.sync_now); - SCMutexUnlock(&pool->return_stack.mutex); SCCondSignal(&pool->return_stack.cond); + SCMutexUnlock(&pool->return_stack.mutex); /* Clear the list of pending packets to return. */ my_pool->pending_pool = NULL; my_pool->pending_head = NULL;