]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: support cpu-map feature through the compile option USE_CPU_AFFINITY on FreeBSD
authorPieter Baauw <piba.nl.dev@gmail.com>
Thu, 17 Sep 2015 19:26:40 +0000 (21:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Sep 2015 20:11:09 +0000 (22:11 +0200)
src/haproxy.c

index ae790c4cf5749fa3542e8a978342d43178c092b5..681109dc5bce9583f5608ff17ee39562dcfa3a01 100644 (file)
 #define __USE_GNU
 #include <sched.h>
 #undef __USE_GNU
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#include <sys/cpuset.h>
+#endif
 #endif
 
 #ifdef DEBUG_FULL
@@ -1780,7 +1784,11 @@ int main(int argc, char **argv)
                if (proc < global.nbproc &&  /* child */
                    proc < LONGBITS &&       /* only the first 32/64 processes may be pinned */
                    global.cpu_map[proc])    /* only do this if the process has a CPU map */
+#ifdef __FreeBSD__
+                       cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(unsigned long), (void *)&global.cpu_map[proc]);
+#else
                        sched_setaffinity(0, sizeof(unsigned long), (void *)&global.cpu_map[proc]);
+#endif
 #endif
                /* close the pidfile both in children and father */
                if (pidfd >= 0) {