From: Amaury Denoyelle Date: Fri, 23 Apr 2021 14:58:08 +0000 (+0200) Subject: BUG/MINOR: cpuset: fix compilation on platform without cpu affinity X-Git-Tag: v2.4-dev17~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6f9c5d2a71375debaf4d3152ea8102ab97dd539;p=thirdparty%2Fhaproxy.git BUG/MINOR: cpuset: fix compilation on platform without cpu affinity The compilation is currently broken on platform without USE_CPU_AFFINITY set. An error has been reported by the cygwin build of the CI. This does not need to be backported. In file included from include/haproxy/global-t.h:27, from include/haproxy/global.h:26, from include/haproxy/fd.h:33, from src/ev_poll.c:22: include/haproxy/cpuset-t.h:32:3: error: #error "No cpuset support implemented on this platform" 32 | # error "No cpuset support implemented on this platform" | ^~~~~ include/haproxy/cpuset-t.h:37:2: error: unknown type name ‘CPUSET_REPR’ 37 | CPUSET_REPR cpuset; | ^~~~~~~~~~~ make: *** [Makefile:944: src/ev_poll.o] Error 1 make: *** Waiting for unfinished jobs.... In file included from include/haproxy/global-t.h:27, from include/haproxy/global.h:26, from include/haproxy/fd.h:33, from include/haproxy/connection.h:30, from include/haproxy/ssl_sock.h:27, from src/ssl_sample.c:30: include/haproxy/cpuset-t.h:32:3: error: #error "No cpuset support implemented on this platform" 32 | # error "No cpuset support implemented on this platform" | ^~~~~ include/haproxy/cpuset-t.h:37:2: error: unknown type name ‘CPUSET_REPR’ 37 | CPUSET_REPR cpuset; | ^~~~~~~~~~~ make: *** [Makefile:944: src/ssl_sample.o] Error 1 --- diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index 03a6a50309..f2cf5ce551 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -24,7 +24,9 @@ #include #include +#ifdef USE_CPU_AFFINITY #include +#endif #include #include diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 47de32a6b1..c653fb49d6 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -13,7 +13,9 @@ #include #include +#ifdef USE_CPU_AFFINITY #include +#endif #include #include #include diff --git a/src/cfgparse.c b/src/cfgparse.c index 507d072fa3..f891697a1d 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -44,7 +44,9 @@ #include #include #include +#ifdef USE_CPU_AFFINITY #include +#endif #include #include #include diff --git a/src/haproxy.c b/src/haproxy.c index e19b8148a7..cd0edcf097 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -92,7 +92,9 @@ #include #include #include +#ifdef USE_CPU_AFFINITY #include +#endif #include #include #include @@ -1270,7 +1272,6 @@ static void init(int argc, char **argv) struct proxy *px; struct post_check_fct *pcf; int ideal_maxconn; - int i; global.mode = MODE_STARTING; old_argv = copy_argv(argc, argv); @@ -1579,11 +1580,16 @@ static void init(int argc, char **argv) global.maxsock = 10; /* reserve 10 fds ; will be incremented by socket eaters */ - for (i = 0; i < MAX_PROCS; ++i) { - ha_cpuset_zero(&global.cpu_map.proc[i]); - ha_cpuset_zero(&global.cpu_map.proc_t1[i]); - ha_cpuset_zero(&global.cpu_map.thread[i]); +#ifdef USE_CPU_AFFINITY + { + int i; + for (i = 0; i < MAX_PROCS; ++i) { + ha_cpuset_zero(&global.cpu_map.proc[i]); + ha_cpuset_zero(&global.cpu_map.proc_t1[i]); + ha_cpuset_zero(&global.cpu_map.thread[i]); + } } +#endif /* in wait mode, we don't try to read the configuration files */ if (!(global.mode & MODE_MWORKER_WAIT)) {