From: Jeff Lucovsky Date: Fri, 11 Feb 2022 13:36:28 +0000 (-0500) Subject: config/thread: Use config'd per-thread stack size X-Git-Tag: suricata-5.0.9~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=266ac395faf543a0a5d3863bccfc42f7519680aa;p=thirdparty%2Fsuricata.git config/thread: Use config'd per-thread stack size Issue: 4550 This commit checks if there's a config setting for threading.stack-size and assigns the value to a global variable for use during thread creation. (cherry picked from commit e4d60f451b8a226e32a3df8e232efe437b11e2e3) --- diff --git a/src/runmodes.c b/src/runmodes.c index c693f0ec58..5cf9dff3c0 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -57,6 +57,7 @@ int debuglog_enabled = 0; int threading_set_cpu_affinity = FALSE; +uint64_t threading_set_stack_size = 0; /* Runmode Global Thread Names */ const char *thread_name_autofp = "RX"; @@ -915,4 +916,20 @@ void RunModeInitialize(void) } SCLogDebug("threading.detect-thread-ratio %f", threading_detect_ratio); + + /* + * Check if there's a configuration setting for the per-thread stack size + * in case the default per-thread stack size is to be adjusted + */ + const char *ss = NULL; + if ((ConfGetValue("threading.stack-size", &ss)) == 1) { + if (ss != NULL) { + if (ParseSizeStringU64(ss, &threading_set_stack_size) < 0) { + FatalError(SC_ERR_INVALID_ARGUMENT, + "Failed to initialize thread_stack_size output, invalid limit: %s", ss); + } + } + } + + SCLogDebug("threading.stack-size %" PRIu64, threading_set_stack_size); } diff --git a/src/runmodes.h b/src/runmodes.h index c1202b75c1..786cc0b52e 100644 --- a/src/runmodes.h +++ b/src/runmodes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -111,6 +111,7 @@ int RunModeNeedsBypassManager(void); extern int threading_set_cpu_affinity; extern float threading_detect_ratio; +extern uint64_t threading_set_stack_size; extern int debuglog_enabled;