Define HA_HAVE_UNSHARE which tests CLONE_FILES with an exception on
NetBSD which has the CLONE_FILES define for clone() but doesn't provide
unshare().
src/thread.c: In function ‘start_extra_tgroup_threads’:
src/thread.c:244:21: error: implicit declaration of function ‘unshare’ [-Werror=implicit-function-declaration]
244 | if (unshare(CLONE_FILES) != 0) {
| ^~~~~~~
No backport needed.
#define IPPROTO_MPTCP 262
#endif
+#if defined(CLONE_FILES) && !defined(__NetBSD__)
+/* NetBSD defines CLONE_FILES but don't have unshare */
+#define HA_HAVE_UNSHARE
+#endif
+
#endif /* _HAPROXY_COMPAT_H */
/*
return 0;
}
else if (strcmp(args[0], "tune.fd.tables") == 0) {
-#ifdef CLONE_FILES
+#ifdef HA_HAVE_UNSHARE
if (strcmp(args[1], "per-thread-group") == 0)
global.tune.options |= GTUNE_NO_TG_FD_SHARING;
else if (strcmp(args[1], "shared") == 0)
hbuf_appendf(&gbuf, "global\n");
hbuf_appendf(&gbuf, "\ttune.memory.hot-size 3145728\n");
hbuf_appendf(&gbuf, "\tssl-server-verify none\n");
-#ifdef CLONE_FILES
+#ifdef HA_HAVE_UNSHARE
/* required for "tune.fd.tables" below */
hbuf_appendf(&gbuf, "\texpose-experimental-directives\n");
hbuf_appendf(&gbuf, "\ttune.fd.tables per-thread-group\n");
struct tgroup_info *tgi = (struct tgroup_info *)arg;
int i;
-#ifdef CLONE_FILES
+#ifdef HA_HAVE_UNSHARE
if (global.tune.options & GTUNE_NO_TG_FD_SHARING)
if (unshare(CLONE_FILES) != 0) {
ha_alert("unshare(CLONE_FILES) failed while trying to use one FD table per thread group (%s)\n", strerror(errno));