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 1acf85f..2289449 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -1157,6 +1157,14 @@
 	/* 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.