diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index a1b16f8387..b3133c27a5 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -439,6 +439,22 @@ int StreamTcpReassemblyConfig(char quiet) segment_pool_mutex = my_segment_lock; segment_pool_pktsizes = my_segment_pktsizes; segment_pool_num = npools; + + uint32_t stream_chunk_prealloc = 250; + ConfNode *chunk = ConfGetNode("stream.reassembly.chunk-prealloc"); + if (chunk) { + uint32_t prealloc = 0; + if (ByteExtractStringUint32(&prealloc, 10, strlen(chunk->val), chunk->val) == -1) + { + SCLogError(SC_ERR_INVALID_ARGUMENT, "chunk-prealloc of " + "%s is invalid", chunk->val); + return -1; + } + stream_chunk_prealloc = prealloc; + } + if (!quiet) + SCLogInfo("stream.reassembly \"chunk-prealloc\": %u", stream_chunk_prealloc); + StreamMsgQueuesInit(stream_chunk_prealloc); return 0; } @@ -449,8 +465,6 @@ int StreamTcpReassembleInit(char quiet) if (StreamTcpReassemblyConfig(quiet) < 0) return -1; - StreamMsgQueuesInit(); - #ifdef DEBUG SCMutexInit(&segment_pool_memuse_mutex, NULL); SCMutexInit(&segment_pool_cnt_mutex, NULL); diff --git a/src/stream.c b/src/stream.c index d6bc3877d9..962530b0b4 100644 --- a/src/stream.c +++ b/src/stream.c @@ -161,12 +161,14 @@ void StreamMsgPoolFree(void *ptr) { } } -void StreamMsgQueuesInit(void) { +void StreamMsgQueuesInit(uint32_t prealloc) { #ifdef DEBUG SCMutexInit(&stream_pool_memuse_mutex, NULL); #endif SCMutexLock(&stream_msg_pool_mutex); - stream_msg_pool = PoolInit(0,250,0,StreamMsgPoolAlloc,StreamMsgInit,NULL,NULL,StreamMsgPoolFree); + stream_msg_pool = PoolInit(0, prealloc, 0, + StreamMsgPoolAlloc,StreamMsgInit, + NULL,NULL,StreamMsgPoolFree); if (stream_msg_pool == NULL) exit(EXIT_FAILURE); /* XXX */ SCMutexUnlock(&stream_msg_pool_mutex); diff --git a/src/stream.h b/src/stream.h index c8453c931c..6a5b754275 100644 --- a/src/stream.h +++ b/src/stream.h @@ -56,7 +56,7 @@ typedef struct StreamMsgQueue_ { } StreamMsgQueue; /* prototypes */ -void StreamMsgQueuesInit(void); +void StreamMsgQueuesInit(uint32_t prealloc); void StreamMsgQueuesDeinit(char); StreamMsg *StreamMsgGetFromPool(void);