From: Willy Tarreau Date: Tue, 13 Oct 2020 15:46:05 +0000 (+0200) Subject: BUG/MINOR: listener: detect and handle shared sockets stopped in other processes X-Git-Tag: v2.3-dev7~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=258b351704055c03f3358b8b44d74ddf784c881c;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/listener.c b/src/listener.c index 1acf85f60c..2289449839 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.