]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proto_tcp: delete fd from fdtab if listen() fails
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 7 Aug 2024 17:31:09 +0000 (19:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Aug 2024 14:33:53 +0000 (16:33 +0200)
If listen() fails, fd should be deleted from fdtab, not just closed. Otherwise,
sock_inet_bind_receiver(), which is called in loop for each receiver, will
obtain the same fd via socket() for the next receiver, registered in the
receivers list. Then, it will bind it again and it will try to re-insert it in
fdtab, and fd_insert() will trigger the BUG_ON(fdtab[fd].owner != NULL) check.

When tcp_bind_listener() code was implemented, the use of fd_delete() was
not generalized and this one remained overlooked.

This can be backported to all stable versions.

src/proto_tcp.c

index faa26de3a482149c753cd376ec70c8c6c0a92acf..25d66bafddb79e0fd85a8d7960d5aec8c32c4dd2 100644 (file)
@@ -694,7 +694,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
  tcp_close_return:
        free_trash_chunk(msg);
        msg = NULL;
-       close(fd);
+       fd_delete(fd);
  tcp_return:
        if (msg && errlen && msg->data) {
                char pn[INET6_ADDRSTRLEN];