From d4575f5765d4a02c33f2eec7febf50591add7ce7 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 9 May 2026 07:34:28 +0200 Subject: [PATCH] pool/thread: remove unused Free callback Not used so not tested. --- src/stream-tcp-reassemble.c | 9 +++------ src/stream-tcp.c | 18 ++++++------------ src/util-pool-thread.c | 32 +++++++++++--------------------- src/util-pool-thread.h | 3 ++- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 6d3aee3581..75616b602c 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -567,12 +567,9 @@ TcpReassemblyThreadCtx *StreamTcpReassembleInitThreadCtx(ThreadVars *tv) SCMutexLock(&segment_thread_pool_mutex); if (segment_thread_pool == NULL) { segment_thread_pool = PoolThreadInit(1, /* thread */ - 0, /* unlimited */ - stream_config.prealloc_segments, - sizeof(TcpSegment), - TcpSegmentPoolAlloc, - TcpSegmentPoolInit, NULL, - TcpSegmentPoolCleanup, NULL); + 0, /* unlimited */ + stream_config.prealloc_segments, sizeof(TcpSegment), TcpSegmentPoolAlloc, + TcpSegmentPoolInit, NULL, TcpSegmentPoolCleanup); ra_ctx->segment_thread_pool_id = 0; SCLogDebug("pool size %d, thread segment_thread_pool_id %d", PoolThreadSize(segment_thread_pool), diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 02edeb3627..abac0d2f39 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -854,12 +854,9 @@ void StreamTcpInitConfig(bool quiet) SCMutexLock(&ssn_pool_mutex); if (ssn_pool == NULL) { ssn_pool = PoolThreadInit(1, /* thread */ - 0, /* unlimited */ - stream_config.prealloc_sessions, - sizeof(TcpSession), - StreamTcpSessionPoolAlloc, - StreamTcpSessionPoolInit, NULL, - StreamTcpSessionPoolCleanup, NULL); + 0, /* unlimited */ + stream_config.prealloc_sessions, sizeof(TcpSession), StreamTcpSessionPoolAlloc, + StreamTcpSessionPoolInit, NULL, StreamTcpSessionPoolCleanup); } SCMutexUnlock(&ssn_pool_mutex); } @@ -6222,12 +6219,9 @@ TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data) SCMutexLock(&ssn_pool_mutex); if (ssn_pool == NULL) { ssn_pool = PoolThreadInit(1, /* thread */ - 0, /* unlimited */ - stream_config.prealloc_sessions, - sizeof(TcpSession), - StreamTcpSessionPoolAlloc, - StreamTcpSessionPoolInit, NULL, - StreamTcpSessionPoolCleanup, NULL); + 0, /* unlimited */ + stream_config.prealloc_sessions, sizeof(TcpSession), StreamTcpSessionPoolAlloc, + StreamTcpSessionPoolInit, NULL, StreamTcpSessionPoolCleanup); stt->ssn_pool_id = 0; SCLogDebug("pool size %d, thread ssn_pool_id %d", PoolThreadSize(ssn_pool), stt->ssn_pool_id); } else { diff --git a/src/util-pool-thread.c b/src/util-pool-thread.c index c343d0cf5f..4878e8b26e 100644 --- a/src/util-pool-thread.c +++ b/src/util-pool-thread.c @@ -41,9 +41,8 @@ * \param thread number of threads this is for. Can start with 1 and be expanded. * Other params are as for PoolInit() */ -PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, - uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), - void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) +PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, + void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *)) { sc_errno = SC_OK; @@ -77,7 +76,7 @@ PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, // SCLogDebug("size %u prealloc_size %u elt_size %u Alloc %p Init %p InitData %p Cleanup %p Free %p", // size, prealloc_size, elt_size, // Alloc, Init, InitData, Cleanup, Free); - e->pool = PoolInit(size, prealloc_size, elt_size, Alloc, Init, InitData, Cleanup, Free); + e->pool = PoolInit(size, prealloc_size, elt_size, Alloc, Init, InitData, Cleanup, NULL); SCMutexUnlock(&e->lock); if (e->pool == NULL) { SCLogDebug("error"); @@ -258,8 +257,7 @@ void PoolThreadTestFree(void *data) static int PoolThreadTestInit01(void) { PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - NULL, NULL, NULL, NULL); + 10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL); FAIL_IF(pt == NULL); PoolThreadFree(pt); PASS; @@ -270,9 +268,7 @@ static int PoolThreadTestInit02(void) int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, - PoolThreadTestAlloc, PoolThreadTestInit, - &i, PoolThreadTestFree, NULL); + 10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree); FAIL_IF(pt == NULL); PoolThreadFree(pt); PASS; @@ -281,8 +277,7 @@ static int PoolThreadTestInit02(void) static int PoolThreadTestGet01(void) { PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - NULL, NULL, NULL, NULL); + 10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL); FAIL_IF(pt == NULL); void *data = PoolThreadGetById(pt, 3); @@ -300,8 +295,7 @@ static int PoolThreadTestGet02(void) int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - PoolThreadTestInit, &i, PoolThreadTestFree, NULL); + 10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree); FAIL_IF_NULL(pt); void *data = PoolThreadGetById(pt, 3); @@ -321,8 +315,7 @@ static int PoolThreadTestReturn01(void) int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - PoolThreadTestInit, &i, PoolThreadTestFree, NULL); + 10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree); FAIL_IF_NULL(pt); void *data = PoolThreadGetById(pt, 3); @@ -346,8 +339,7 @@ static int PoolThreadTestReturn01(void) static int PoolThreadTestGrow01(void) { PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - NULL, NULL, NULL, NULL); + 10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL); FAIL_IF_NULL(pt); FAIL_IF(PoolThreadExpand(pt) < 0); @@ -360,8 +352,7 @@ static int PoolThreadTestGrow02(void) int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - PoolThreadTestInit, &i, PoolThreadTestFree, NULL); + 10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree); FAIL_IF_NULL(pt); FAIL_IF(PoolThreadExpand(pt) < 0); @@ -374,8 +365,7 @@ static int PoolThreadTestGrow03(void) int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ - 10, 5, 10, PoolThreadTestAlloc, - PoolThreadTestInit, &i, PoolThreadTestFree, NULL); + 10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree); FAIL_IF_NULL(pt); FAIL_IF(PoolThreadExpand(pt) < 0); diff --git a/src/util-pool-thread.h b/src/util-pool-thread.h index 7d6ad1f1a5..93e129e5a6 100644 --- a/src/util-pool-thread.h +++ b/src/util-pool-thread.h @@ -65,7 +65,8 @@ void PoolThreadRegisterTests(void); * \note same as PoolInit() except for "threads" * \param threads number of threads to use this * \retval pt thread pool or NULL on error */ -PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)); +PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, + void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *)); /** \brief grow a thread pool by one * \note copies settings from initial PoolThreadInit() call