From: William Lallemand Date: Mon, 7 Sep 2026 13:39:53 +0000 (+0200) Subject: BUILD: fd: unshare is not available on NetBSD X-Git-Tag: v3.5-dev7~69 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=5e9662ddd63a730235deec27489c7e8897fea21d;p=haproxy.git BUILD: fd: unshare is not available on NetBSD 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. --- diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h index 3f0f0b393..1f486835d 100644 --- a/include/haproxy/compat.h +++ b/include/haproxy/compat.h @@ -355,6 +355,11 @@ typedef struct { } empty_t; #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 */ /* diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index e16eadab8..af1acb40f 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1521,7 +1521,7 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, 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) diff --git a/src/haload_init.c b/src/haload_init.c index 74dac49bb..27709ce42 100644 --- a/src/haload_init.c +++ b/src/haload_init.c @@ -438,7 +438,7 @@ void haproxy_init_args(int argc, char **argv) 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"); diff --git a/src/thread.c b/src/thread.c index 24f7aa751..6006e8cb2 100644 --- a/src/thread.c +++ b/src/thread.c @@ -242,7 +242,7 @@ void *start_extra_tgroup_threads(void *arg) 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));