]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listeners: move fd_stop_recv() to the receiver's socket code
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Sep 2020 16:20:37 +0000 (18:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Oct 2020 09:27:30 +0000 (11:27 +0200)
fd_stop_recv() has nothing to do in the generic listener code, it's per
protocol as some don't need it. For instance with abns@ it could even
lead to fd_stop_recv(-1). And later with QUIC we don't want to touch
the fd at all! It used to be that since commit f2cb169487 delegating
fd manipulation to their respective threads it wasn't possible to call
it down there but it's not the case anymore, so let's perform the action
in the protocol-specific code.

src/listener.c
src/proto_tcp.c
src/proto_uxst.c

index b2a6862ca99da44980d70b5dc0acde8c03a7b39c..39f5b340f6e35e69b993fa7df813cc5e0e6d1dd2 100644 (file)
@@ -362,7 +362,6 @@ int pause_listener(struct listener *l)
 
        MT_LIST_DEL(&l->wait_queue);
 
-       fd_stop_recv(l->rx.fd);
        listener_set_state(l, LI_PAUSED);
 
        if (px && !px->li_ready) {
index 83b23b9b551590943c9bd6bc207917b7d0b4e5ac..b9bc97e42555ded89346a4d9e9251a4583479759 100644 (file)
@@ -743,6 +743,7 @@ int tcp_pause_listener(struct listener *l)
        if (shutdown(l->rx.fd, SHUT_RD) != 0)
                goto check_already_done; /* show always be OK */
 
+       fd_stop_recv(l->rx.fd);
        return 1;
 
  check_already_done:
@@ -752,11 +753,15 @@ int tcp_pause_listener(struct listener *l)
         */
        opt_val = 0;
        opt_len = sizeof(opt_val);
-       if (getsockopt(l->rx.fd, SOL_SOCKET, SO_ACCEPTCONN, &opt_val, &opt_len) == -1)
+       if (getsockopt(l->rx.fd, SOL_SOCKET, SO_ACCEPTCONN, &opt_val, &opt_len) == -1) {
+               fd_stop_recv(l->rx.fd);
                return 0; /* the socket is really unrecoverable */
+       }
 
-       if (!opt_val)
+       if (!opt_val) {
+               fd_stop_recv(l->rx.fd);
                return 1; /* already paused by another process */
+       }
 
        /* something looks fishy here */
        return -1;
index bafe97dcfbd53c0817197201e09dd9df8cf9f38e..c477d193dcc318df4ee53994bca6192355b64912 100644 (file)
@@ -151,7 +151,8 @@ static void uxst_add_listener(struct listener *listener, int port)
 /* Pause a listener. Returns < 0 in case of failure, 0 if the listener
  * was totally stopped, or > 0 if correctly paused. Nothing is done for
  * plain unix sockets since currently it's the new process which handles
- * the renaming. Abstract sockets are completely unbound.
+ * the renaming. Abstract sockets are completely unbound and closed so
+ * there's no need to stop the poller.
  */
 static int uxst_pause_listener(struct listener *l)
 {