From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VA25L-0001qc-Hf for qemu-devel@nongnu.org; Thu, 15 Aug 2013 14:15:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VA25G-0005u7-U2 for qemu-devel@nongnu.org; Thu, 15 Aug 2013 14:15:47 -0400 From: Taimoor Date: Thu, 15 Aug 2013 23:13:28 +0500 Message-Id: <1376590408-7037-1-git-send-email-tmirza@codesourcery.com> Subject: [Qemu-devel] [PATCH v2] slirp: Port redirection option behave differently on Linux and Windows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Taimoor Mirza From: Taimoor Mirza port redirection code uses SO_REUSEADDR socket option before binding to host port. Behavior of SO_REUSEADDR is different on Windows and Linux. Relaunching QEMU with same host and guest port redirection values on Linux throws error but on Windows it does not throw any error. Problem is discussed in http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg03089.html Signed-off-by: Taimoor Mirza --- Changed #ifdef to #ifndef as SO_REUSEADDR should not be set in case of Windows. slirp/socket.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/slirp/socket.c b/slirp/socket.c index 8e8819c..e4685bb 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -1,4 +1,4 @@ -/* +x/* * Copyright (c) 1995 Danny Gasparovski. * * Please read the file COPYRIGHT for the @@ -627,7 +627,9 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, 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 (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) || (listen(s,1) < 0)) { int tmperrno = errno; /* Don't clobber the real reason we failed */ -- 1.7.5.4