]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: improve error handling of ssn/segment pools
authorVictor Julien <victor@inliniac.net>
Fri, 13 Oct 2017 07:05:02 +0000 (09:05 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 16 Oct 2017 12:10:05 +0000 (14:10 +0200)
With large number of threads the default memcaps lead to pool setup
failures. Make sure these are reported properly so that the user
knows what is going on.

Bug: #2226

src/stream-tcp-reassemble.c
src/stream-tcp.c

index e61e3db701567a1a2b336a6aa47d227cfb056d0d..4665a9b1a3822e96090d7aca12eb8ba5fa64abc7 100644 (file)
@@ -444,8 +444,11 @@ TcpReassemblyThreadCtx *StreamTcpReassembleInitThreadCtx(ThreadVars *tv)
                 ra_ctx->segment_thread_pool_id);
     }
     SCMutexUnlock(&segment_thread_pool_mutex);
-    if (ra_ctx->segment_thread_pool_id < 0 || segment_thread_pool == NULL)
-        abort();
+    if (ra_ctx->segment_thread_pool_id < 0 || segment_thread_pool == NULL) {
+        SCLogError(SC_ERR_MEM_ALLOC, "failed to setup/expand stream segment pool. Expand stream.reassembly.memcap?");
+        StreamTcpReassembleFreeThreadCtx(ra_ctx);
+        SCReturnPtr(NULL, "TcpReassemblyThreadCtx");
+    }
 
     SCReturnPtr(ra_ctx, "TcpReassemblyThreadCtx");
 }
index dfc956c13a5ae7ccf72fbbc11c382fd3491e4dc2..d99d0c255dfdd84c11850c3ca34d6d049769d578 100644 (file)
@@ -4984,8 +4984,10 @@ TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data)
         SCLogDebug("pool size %d, thread ssn_pool_id %d", PoolThreadSize(ssn_pool), stt->ssn_pool_id);
     }
     SCMutexUnlock(&ssn_pool_mutex);
-    if (stt->ssn_pool_id < 0 || ssn_pool == NULL)
+    if (stt->ssn_pool_id < 0 || ssn_pool == NULL) {
+        SCLogError(SC_ERR_MEM_ALLOC, "failed to setup/expand stream session pool. Expand stream.memcap?");
         SCReturnInt(TM_ECODE_FAILED);
+    }
 
     SCReturnInt(TM_ECODE_OK);
 }