From patchwork Wed Oct 2 10:23:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ottlik X-Patchwork-Id: 279682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 82DFF2C0086 for ; Wed, 2 Oct 2013 20:26:06 +1000 (EST) Received: from localhost ([::1]:35185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRJd6-0004vy-CB for incoming@patchwork.ozlabs.org; Wed, 02 Oct 2013 06:26:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRJbD-0002JD-Qd for qemu-devel@nongnu.org; Wed, 02 Oct 2013 06:24:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRJb4-0005jo-Op for qemu-devel@nongnu.org; Wed, 02 Oct 2013 06:24:07 -0400 Received: from mailhost.fzi.de ([141.21.8.250]:8570 helo=EX-E-1.perimeter.fzi.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRJb4-0005jP-I2 for qemu-devel@nongnu.org; Wed, 02 Oct 2013 06:23:58 -0400 Received: from ex-ca-ht-1.fzi.de (141.21.32.98) by EX-E-1.perimeter.fzi.de (141.21.8.250) with Microsoft SMTP Server (TLS) id 14.2.347.0; Wed, 2 Oct 2013 12:23:53 +0200 Received: from orcrist.fzi.de (2a02:788:13:20:7c9e:9b2:4fe6:6154) by ex-ca-ht-1.fzi.de (2a02:788:13:20::8d15:2062) with Microsoft SMTP Server id 14.3.158.1; Wed, 2 Oct 2013 12:23:57 +0200 Received: by orcrist.fzi.de (Postfix, from userid 330838105) id 4CEF81C072C; Wed, 2 Oct 2013 12:23:57 +0200 (CEST) From: Sebastian Ottlik To: Date: Wed, 2 Oct 2013 12:23:16 +0200 Message-ID: <1380709396-6063-6-git-send-email-ottlik@fzi.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380709396-6063-1-git-send-email-ottlik@fzi.de> References: <1380709396-6063-1-git-send-email-ottlik@fzi.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 141.21.8.250 Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, ottlik@fzi.de, stefanha@redhat.com, sw@weilnetz.de Subject: [Qemu-devel] [PATCH v6 5/5] util: call socket_set_fast_reuse instead of setting SO_REUSEADDR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. Signed-off-by: Sebastian Ottlik --- util/qemu-sockets.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 095716e..6b97dc1 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -155,7 +155,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) continue; } - qemu_setsockopt(slisten, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + socket_set_fast_reuse(slisten); #ifdef IPV6_V6ONLY if (e->ai_family == PF_INET6) { /* listen on both ipv4 and ipv6 */ @@ -274,7 +274,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress, error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); return -1; } - qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + socket_set_fast_reuse(sock); if (connect_state != NULL) { qemu_set_nonblock(sock); } @@ -455,7 +455,7 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp) error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); goto err; } - qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + socket_set_fast_reuse(sock); /* bind socket */ if (bind(sock, local->ai_addr, local->ai_addrlen) < 0) {