[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v1 4/9] sockets: factor out create_fast_reuse_socket
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PULL v1 4/9] sockets: factor out create_fast_reuse_socket |
Date: |
Tue, 5 Sep 2017 10:22:25 +0100 |
From: Knut Omang <address@hidden>
Another refactoring step to prepare for fixing the problem
exposed with the test-listen test in the previous commit
Signed-off-by: Knut Omang <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Signed-off-by: Daniel P. Berrange <address@hidden>
---
util/qemu-sockets.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b4a2f243f4..d0d20476e5 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -149,6 +149,16 @@ int inet_ai_family_from_address(InetSocketAddress *addr,
return PF_UNSPEC;
}
+static int create_fast_reuse_socket(struct addrinfo *e)
+{
+ int slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
+ if (slisten < 0) {
+ return -1;
+ }
+ socket_set_fast_reuse(slisten);
+ return slisten;
+}
+
static int try_bind(int socket, InetSocketAddress *saddr, struct addrinfo *e)
{
#ifndef IPV6_V6ONLY
@@ -253,7 +263,8 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
uaddr,INET6_ADDRSTRLEN,uport,32,
NI_NUMERICHOST | NI_NUMERICSERV);
- slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
+
+ slisten = create_fast_reuse_socket(e);
if (slisten < 0) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to create socket");
@@ -261,8 +272,6 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
continue;
}
- socket_set_fast_reuse(slisten);
-
port_min = inet_getport(e);
port_max = saddr->has_to ? saddr->to + port_offset : port_min;
for (p = port_min; p <= port_max; p++) {
--
2.13.5
- [Qemu-devel] [PULL v1 0/9] Merge QEMU I/O 2017/09/05, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 3/9] sockets: factor out a new try_bind() function, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 4/9] sockets: factor out create_fast_reuse_socket,
Daniel P. Berrange <=
- [Qemu-devel] [PULL v1 1/9] io: fix temp directory used by test-io-channel-tls test, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 7/9] io: fix typo in docs comment for qio_channel_read, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 2/9] tests: Add test-listen - a stress test for QEMU socket listen, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 6/9] util: remove the obsolete non-blocking connect, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 5/9] sockets: Handle race condition between binds to the same port, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 9/9] io: fix check for handshake completion in TLS test, Daniel P. Berrange, 2017/09/05
- [Qemu-devel] [PULL v1 8/9] io: add new qio_channel_{readv, writev, read, write}_all functions, Daniel P. Berrange, 2017/09/05
- Re: [Qemu-devel] [PULL v1 0/9] Merge QEMU I/O 2017/09/05, Peter Maydell, 2017/09/05