From c723b9bf4790ad5f74746fd6c1011836373ac6e5 Mon Sep 17 00:00:00 2001 From: Ellenor Malik Date: Sat, 12 Oct 2019 14:25:48 -0700 Subject: [PATCH] This commit incorporates @janicez' interpretation of the fix suggested by amdj on charybdis-ircd/charybdis#291 for what I am calling the 'bandb bug'. per @aaronmdjones, "I'd hazard a guess that O_CLOEXEC isn't being set somewhere (or isn't being respected, if it is). I'll have a look into this, but without a system to test and reproduce on, I can't promise anything." --- src/listener.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/listener.c b/src/listener.c index 1f64fbef..857ac63d 100644 --- a/src/listener.c +++ b/src/listener.c @@ -44,6 +44,7 @@ #include "hash.h" #include "s_assert.h" #include "logger.h" +#include "fcntl.h" #ifndef INADDR_NONE #define INADDR_NONE ((unsigned int) 0xffffffff) @@ -271,6 +272,8 @@ inetport(struct Listener *listener) listener->F = F; + // Added as workaround for 'bandb listen' (charybdis-ircd/charybdis#291) bug by ellenor - let's see if it works + fcntl (rb_get_fd(listener->F), F_SETFD, fcntl(rb_get_fd(listener->F), F_GETFD, 0) | FD_CLOEXEC); rb_accept_tcp(listener->F, accept_precallback, accept_callback, listener); return 1; } @@ -382,6 +385,9 @@ inetport_sctp(struct Listener *listener) listener->F = F; + // Added as workaround for 'bandb listen' (charybdis-ircd/charybdis#291) bug by ellenor - let's see if it works + // Not applicable to mainline Charybdis 3.5.7 because this is for SCTP, not TCP, but the bug still occurs. + fcntl (rb_get_fd(listener->F), F_SETFD, fcntl(rb_get_fd(listener->F), F_GETFD, 0) | FD_CLOEXEC); rb_accept_tcp(listener->F, accept_precallback, accept_callback, listener); return 1; #endif