From 258b351704055c03f3358b8b44d74ddf784c881c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 13 Oct 2020 17:46:05 +0200 Subject: [PATCH] BUG/MINOR: listener: detect and handle shared sockets stopped in other processes It may happen that during a temporary listener pause resulting from a SIGTTOU, one process gets one of its sockets disabled by another process and will not be able to recover from this situation by itself. For the protocols supporting this (TCPv4 and TCPv6 at the moment) this situation is detectable, so when this happens, let's put the listener into the PAUSED state so that it remains consistent with the real socket state. One nice effect is that just sending the SIGTTIN signal to the process is enough to recover the socket in this case. There is no need to backport this, this behavior has been there forever and the fix requires to reimplement the getsockopt() call there. --- src/listener.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/listener.c b/src/listener.c index 1acf85f60..228944983 100644 --- a/src/listener.c +++ b/src/listener.c @@ -1157,6 +1157,14 @@ void listener_accept(int fd) /* pause the listener for up to 100 ms */ expire = tick_add(now_ms, 100); + /* This may be a shared socket that was paused by another process. + * Let's put it to pause in this case. + */ + if (l->rx.proto && l->rx.proto->rx_listening(&l->rx) == 0) { + pause_listener(l); + goto end; + } + limit_global: /* (re-)queue the listener to the global queue and set it to expire no * later than ahead. The listener turns to LI_LIMITED. -- 2.47.3