aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc.c3
-rw-r--r--socket.c4
-rw-r--r--tcp_subr.c6
-rw-r--r--udp.c4
4 files changed, 6 insertions, 11 deletions
diff --git a/misc.c b/misc.c
index 40f4a6a..49d77f8 100644
--- a/misc.c
+++ b/misc.c
@@ -207,8 +207,7 @@ int fork_exec(struct socket *so, const char *ex, int do_pty)
so->s = accept(s, (struct sockaddr *)&addr, &addrlen);
} while (so->s < 0 && errno == EINTR);
closesocket(s);
- opt = 1;
- qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
+ socket_set_fast_reuse(so->s);
opt = 1;
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
qemu_set_nonblock(so->s);
diff --git a/socket.c b/socket.c
index c2386bb..6643d67 100644
--- a/socket.c
+++ b/socket.c
@@ -633,9 +633,7 @@ struct socket *tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
addr.sin_port = hport;
if (((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0) ||
-#ifndef _WIN32
- (qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)) < 0) ||
-#endif
+ (socket_set_fast_reuse(s) < 0) ||
(bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) ||
(listen(s, 1) < 0)) {
int tmperrno = errno; /* Don't clobber the real reason we failed */
diff --git a/tcp_subr.c b/tcp_subr.c
index 3b8a37e..4d2c3ab 100644
--- a/tcp_subr.c
+++ b/tcp_subr.c
@@ -335,8 +335,7 @@ int tcp_fconnect(struct socket *so)
struct sockaddr_in addr;
qemu_set_nonblock(s);
- opt = 1;
- qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ socket_set_fast_reuse(s);
opt = 1;
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
@@ -425,8 +424,7 @@ void tcp_connect(struct socket *inso)
return;
}
qemu_set_nonblock(s);
- opt = 1;
- qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
+ socket_set_fast_reuse(s);
opt = 1;
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
socket_set_nodelay(s);
diff --git a/udp.c b/udp.c
index dfc314a..9bc264f 100644
--- a/udp.c
+++ b/udp.c
@@ -344,7 +344,7 @@ struct socket *udp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
{
struct sockaddr_in addr;
struct socket *so;
- socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1;
+ socklen_t addrlen = sizeof(struct sockaddr_in);
so = socreate(slirp);
if (!so) {
@@ -362,7 +362,7 @@ struct socket *udp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
udp_detach(so);
return NULL;
}
- qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
+ socket_set_fast_reuse(so->s);
getsockname(so->s, (struct sockaddr *)&addr, &addrlen);
so->so_fport = addr.sin_port;