]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: listener: detect and handle shared sockets stopped in other processes
authorWilly Tarreau <w@1wt.eu>
Tue, 13 Oct 2020 15:46:05 +0000 (17:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 Oct 2020 16:15:33 +0000 (18:15 +0200)
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

index 1acf85f60c977d386ff6f53c2cadbcbf9c34da5d..2289449839395d8b742f96e8cae44f6376f0c024 100644 (file)
@@ -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 <expire> ahead. The listener turns to LI_LIMITED.