From: Eric Leblond Date: Fri, 26 Oct 2012 08:31:13 +0000 (+0200) Subject: affinity: avoid to init structure twice X-Git-Tag: suricata-1.4rc1~45 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9cb8ce89f111d3528d6209265f66574169a1d6c;p=thirdparty%2Fsuricata.git affinity: avoid to init structure twice In unix socket mode, suricata was doing multiple init of the structure. This was not needed and caused a memory leak in mutex creation. --- diff --git a/src/util-affinity.c b/src/util-affinity.c index d61b70d0e2..875da6ff89 100644 --- a/src/util-affinity.c +++ b/src/util-affinity.c @@ -83,6 +83,8 @@ ThreadsAffinityType thread_affinity[MAX_CPU_SET] = { }; +int thread_affinity_init_done = 0; + /** * \brief find affinity by its name * \retval a pointer to the affinity or NULL if not found @@ -111,7 +113,7 @@ static void AffinitySetupInit() for (j = 0; j < ncpu; j++) { CPU_SET(j, cs); } - SCMutexInit(&thread_affinity[i].taf_mutex, NULL); + SCMutexInit(&thread_affinity[i].taf_mutex, NULL); } return; } @@ -191,7 +193,10 @@ void AffinitySetupLoadFromConfig() ConfNode *root = ConfGetNode("threading.cpu-affinity"); ConfNode *affinity; - AffinitySetupInit(); + if (thread_affinity_init_done == 0) { + AffinitySetupInit(); + thread_affinity_init_done = 1; + } SCLogDebug("Load affinity from config\n"); if (root == NULL) {