]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proto: skip socket setup for duped FDs
authorWilly Tarreau <w@1wt.eu>
Mon, 27 Feb 2023 15:40:54 +0000 (16:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Apr 2023 15:41:26 +0000 (17:41 +0200)
It's not strictly necessary, but it's still better to avoid setting
up the same socket multiple times when it's being duplicated to a few
FDs. We don't change that for inherited ones however since they may
really need to be set up, so we only skip duplicated ones.

src/proto_tcp.c
src/proto_uxst.c

index 4691e165a5cc68588baa3ea75d3ab571b9c6f41c..2e5c36a51e8992ceefb6ebf1127e173f552a13b2 100644 (file)
@@ -603,6 +603,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
                goto tcp_return;
        }
 
+       if (listener->rx.flags & RX_F_MUST_DUP)
+               goto done;
+
        fd = listener->rx.fd;
 
        if (listener->bind_conf->options & BC_O_NOLINGER)
@@ -723,6 +726,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
                setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
 #endif
 
+ done:
        /* the socket is ready */
        listener_set_state(listener, LI_LISTEN);
        goto tcp_return;
index ed1fa53efdfd77c6183a1dd1d73fe4bb8aa8f856..7988e00d15db323fc1c6bb3ec4806cb4cc79a49a 100644 (file)
@@ -124,6 +124,9 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
                goto uxst_return;
        }
 
+       if (listener->rx.flags & RX_F_MUST_DUP)
+               goto done;
+
        fd = listener->rx.fd;
        ready = sock_accepting_conn(&listener->rx) > 0;
 
@@ -134,6 +137,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
                goto uxst_close_return;
        }
 
+ done:
        /* the socket is now listening */
        listener_set_state(listener, LI_LISTEN);
        return err;