From: Martin Willi Date: Fri, 12 Dec 2008 09:10:52 +0000 (-0000) Subject: leak detective binds execution to a signle core, avoids corruption on SMP machines X-Git-Tag: 4.2.10~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a485e90bded80ffde894dcc438873a2daec127d;p=thirdparty%2Fstrongswan.git leak detective binds execution to a signle core, avoids corruption on SMP machines --- diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c index abb470f46a..63d1635f6c 100644 --- a/src/libstrongswan/utils/leak_detective.c +++ b/src/libstrongswan/utils/leak_detective.c @@ -15,6 +15,8 @@ * $Id$ */ +#define _GNU_SOURCE +#include #include #include #include @@ -473,6 +475,16 @@ leak_detective_t *leak_detective_create() if (getenv("LEAK_DETECTIVE_DISABLE") == NULL) { + cpu_set_t mask; + + CPU_ZERO(&mask); + CPU_SET(0, &mask); + + if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) != 0) + { + fprintf(stderr, "setting CPU affinity failed: %m"); + } + lib->leak_detective = TRUE; install_hooks(); }