Files
qemu/util
Stefan Hajnoczi 9b0ee423a1 sockets: update SOCKET_ADDRESS_TYPE_FD listen(2) backlog
socket_get_fd() fails with the error "socket_get_fd: too many
connections" if the given listen backlog value is not 1.

Not all callers set the backlog to 1. For example, commit
582d4210eb ("qemu-nbd: Use SOMAXCONN for
socket listen() backlog") uses SOMAXCONN. This will always fail with in
socket_get_fd().

This patch calls listen(2) on the fd to update the backlog value. The
socket may already be in the listen state. I have tested that this works
on Linux 5.10 and macOS Catalina.

As a bonus this allows us to detect when the fd cannot listen. Now we'll
be able to catch unbound or connected fds in socket_listen().

Drop the num argument from socket_get_fd() since this function is also
called by socket_connect() where a listen backlog value does not make
sense.

Fixes: e5b6353cf2 ("socket: Add backlog parameter to socket_listen")
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210310173004.420190-1-stefanha@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 37179e9ea4)
Signed-off-by: Michael Roth <michael.roth@amd.com>
2021-10-14 15:37:52 -05:00
..
2021-04-01 14:28:39 +02:00
2020-01-06 18:41:32 +04:00
2019-09-11 08:46:17 +02:00
2021-04-01 15:27:44 +04:00
2020-12-10 17:16:44 +01:00
2018-12-20 10:29:08 +01:00
2018-08-24 20:26:37 +02:00
2018-06-29 12:32:10 +02:00
2021-04-01 15:27:44 +04:00