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 03a6a50..f2cf5ce 100644
--- a/include/haproxy/global-t.h
+++ b/include/haproxy/global-t.h
@@ -24,7 +24,9 @@
#include <haproxy/api-t.h>
#include <haproxy/buf-t.h>
+#ifdef USE_CPU_AFFINITY
#include <haproxy/cpuset-t.h>
+#endif
#include <haproxy/freq_ctr-t.h>
#include <haproxy/vars-t.h>
diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c
index 47de32a..c653fb4 100644
--- a/src/cfgparse-global.c
+++ b/src/cfgparse-global.c
@@ -13,7 +13,9 @@
#include <haproxy/buf.h>
#include <haproxy/cfgparse.h>
+#ifdef USE_CPU_AFFINITY
#include <haproxy/cpuset.h>
+#endif
#include <haproxy/compression.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 507d072..f891697 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -44,7 +44,9 @@
#include <haproxy/channel.h>
#include <haproxy/check.h>
#include <haproxy/chunk.h>
+#ifdef USE_CPU_AFFINITY
#include <haproxy/cpuset.h>
+#endif
#include <haproxy/connection.h>
#include <haproxy/errors.h>
#include <haproxy/filters.h>
diff --git a/src/haproxy.c b/src/haproxy.c
index e19b814..cd0edcf 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -92,7 +92,9 @@
#include <haproxy/chunk.h>
#include <haproxy/cli.h>
#include <haproxy/connection.h>
+#ifdef USE_CPU_AFFINITY
#include <haproxy/cpuset.h>
+#endif
#include <haproxy/dns.h>
#include <haproxy/dynbuf.h>
#include <haproxy/errors.h>
@@ -1270,7 +1272,6 @@
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 @@
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)) {