The stream chunk pool contains preallocating stream chunks (StreamMsg).
These are used for raw reassembly, used in raw content inspection by
the detection engine. The default setting so far has been 250, which
was hardcoded. This meant that in setups that needed more, allocs and
frees would be happen constantly.
This patch introduces a yaml option to set the 'prealloc' value in the
pool. The default is still 250.
stream.reassembly.chunk-prealloc
Related to feature #1093.
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;
}
if (StreamTcpReassemblyConfig(quiet) < 0)
return -1;
- StreamMsgQueuesInit();
-
#ifdef DEBUG
SCMutexInit(&segment_pool_memuse_mutex, NULL);
SCMutexInit(&segment_pool_cnt_mutex, NULL);
}
}
-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);
} StreamMsgQueue;
/* prototypes */
-void StreamMsgQueuesInit(void);
+void StreamMsgQueuesInit(uint32_t prealloc);
void StreamMsgQueuesDeinit(char);
StreamMsg *StreamMsgGetFromPool(void);