qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Set SO_REUSEADDR at the right time
@ 2006-01-17  0:03 Nickolai Zeldovich
  2006-01-22 23:32 ` John R. Hogerhuis
  0 siblings, 1 reply; 3+ messages in thread
From: Nickolai Zeldovich @ 2006-01-17  0:03 UTC (permalink / raw)
  To: qemu-devel

It looks like qemu (at least version 0.7.2, which is what I'm running
here) doesn't set SO_REUSEADDR before calling bind(), which makes that
fairly useless.  This obvious patch moves up setting SO_REUSEADDR to the
right place, just before bind().

Apologies if this is already fixed in 0.8.0.

-- kolya

--- slirp/socket.c.orig	2006-01-16 15:54:40.993024000 -0800
+++ slirp/socket.c	2006-01-16 15:55:06.049849000 -0800
@@ -573,6 +573,7 @@
 	addr.sin_port = port;

 	if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) ||
+	    (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) ||
 	    (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
 	    (listen(s,1) < 0)) {
 		int tmperrno = errno; /* Don't clobber the real reason we failed */
@@ -587,7 +588,6 @@
 #endif
 		return NULL;
 	}
-	setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
 	setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));

 	getsockname(s,(struct sockaddr *)&addr,&addrlen);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-01-23  5:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-17  0:03 [Qemu-devel] Set SO_REUSEADDR at the right time Nickolai Zeldovich
2006-01-22 23:32 ` John R. Hogerhuis
2006-01-23  5:49   ` Michael Renzmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).