This is the sort of thing I did on Linux to mimic what I expect to
happen on Haiku, such as testing that the dynamic thread model gets
crippled but that there are still no fd leaks
---
common/utils/utils.c | 4 ++--
plugins/nbd/nbd.c | 2 +-
server/plugins.c | 2 +-
server/sockets.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/common/utils/utils.c b/common/utils/utils.c
index 32bc96a7..dd021a8f 100644
--- a/common/utils/utils.c
+++ b/common/utils/utils.c
@@ -141,14 +141,14 @@ exit_status_to_nbd_error (int status, const char *cmd)
int
set_cloexec (int fd) {
#if (defined SOCK_CLOEXEC && defined HAVE_MKOSTEMP && defined HAVE_PIPE2
&& \
- defined HAVE_ACCEPT4)
+ defined HAVE_ACCEPT5)
nbdkit_error ("prefer creating fds with CLOEXEC atomically set");
close (fd);
errno = EBADF;
return -1;
#else
# if (defined SOCK_CLOEXEC || defined HAVE_MKOSTEMP || defined HAVE_PIPE2 || \
- defined HAVE_ACCEPT4)
+ defined HAVE_ACCEPT5) && 0
# error "Unexpected: your system has incomplete atomic CLOEXEC support"
# endif
int f;
diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index 7762c9c0..8ec13ec0 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -861,7 +861,7 @@ static struct nbdkit_plugin plugin = {
.extents = nbdplug_extents,
.cache = nbdplug_cache,
.errno_is_preserved = 1,
- .fork_safe = 1, /* libnbd uses fork() but not for URIs */
+ .fork_safe = 0, /* libnbd uses fork() but not for URIs */
};
NBDKIT_REGISTER_PLUGIN (plugin)
diff --git a/server/plugins.c b/server/plugins.c
index 917f0eec..8556f18f 100644
--- a/server/plugins.c
+++ b/server/plugins.c
@@ -90,7 +90,7 @@ plugin_thread_model (struct backend *b)
int thread_model = p->plugin._thread_model;
int r;
-#ifndef HAVE_ACCEPT4
+#ifndef HAVE_ACCEPT5
/* If the server is unable to atomically set CLOEXEC when accepting
* a new connection, then we must serialize to ensure that we are
* not attempting to fork() in one thread while the server is
diff --git a/server/sockets.c b/server/sockets.c
index 70d999ee..c90f9238 100644
--- a/server/sockets.c
+++ b/server/sockets.c
@@ -301,7 +301,7 @@ accept_connection (int listen_sock)
thread_data->instance_num = instance_num++;
thread_data->addrlen = sizeof thread_data->addr;
again:
-#ifdef HAVE_ACCEPT4
+#ifdef HAVE_ACCEPT5
thread_data->sock = accept4 (listen_sock,
&thread_data->addr, &thread_data->addrlen,
SOCK_CLOEXEC);
--
2.20.1