From 77f2b6a7a967d1c29f883e70169da289f13e234e Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Mon, 24 Jan 2011 13:26:49 +0100 Subject: [PATCH] Make runmode parse affinity settings. This patch modifies runmode to parse configuration file related to affinity settings. It also prepare the export of the set_cpu_affinity which was previously local. It is now used in the affinity and tm-threads files. Signed-off-by: Eric Leblond --- src/runmodes.c | 7 ++++++- src/runmodes.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/runmodes.c b/src/runmodes.c index f589b23a38..76586f94f9 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -33,6 +33,7 @@ #include "util-affinity.h" #include "conf.h" #include "queue.h" +#include "runmodes.h" #include "alert-fastlog.h" #include "alert-prelude.h" @@ -152,7 +153,6 @@ static void SetupOutputs(ThreadVars *tv) } } -static int threading_set_cpu_affinity = FALSE; static float threading_detect_ratio = 1; /** @@ -160,9 +160,14 @@ static float threading_detect_ratio = 1; */ static void RunModeInitialize(void) { + threading_set_cpu_affinity = FALSE; if ((ConfGetBool("threading.set_cpu_affinity", &threading_set_cpu_affinity)) == 0) { threading_set_cpu_affinity = FALSE; } + /* try to get custom cpu mask value if needed */ + if (threading_set_cpu_affinity == TRUE) { + AffinitySetupLoadFromConfig(); + } if ((ConfGetFloat("threading.detect_thread_ratio", &threading_detect_ratio)) != 1) { threading_detect_ratio = 1; } diff --git a/src/runmodes.h b/src/runmodes.h index 35827122fa..fa8aa71eb5 100644 --- a/src/runmodes.h +++ b/src/runmodes.h @@ -53,5 +53,8 @@ int RunModeErfDagAuto(DetectEngineCtx *, char *); void RunModeShutDown(void); int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx, char *file); + + +int threading_set_cpu_affinity; #endif /* __RUNMODES_H__ */