From patchwork Fri Sep 16 14:25:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 114929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DA8CFB70C7 for ; Sat, 17 Sep 2011 00:26:31 +1000 (EST) Received: from localhost ([::1]:42891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4ZN6-0003Jy-Rg for incoming@patchwork.ozlabs.org; Fri, 16 Sep 2011 10:26:28 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4ZMu-0002wA-73 for qemu-devel@nongnu.org; Fri, 16 Sep 2011 10:26:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4ZMp-0004yo-Fs for qemu-devel@nongnu.org; Fri, 16 Sep 2011 10:26:15 -0400 Received: from mail-wy0-f175.google.com ([74.125.82.175]:40566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4ZMp-0004y7-2f for qemu-devel@nongnu.org; Fri, 16 Sep 2011 10:26:11 -0400 Received: by wyh5 with SMTP id 5so2976511wyh.34 for ; Fri, 16 Sep 2011 07:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=GKOYXeZinVfsQ8uVkdIZUbEM3TGxWkGSXxsRNqCNmuc=; b=Usq3nyjGWfxQ+4trm7bQTdH6TEjkLCTxxysyzJzKzNlTes0ZtFFlNb941gpce5UlwJ kNgbj/l12yWJFDeBlXctw/tjsUvjL4ALNGorWvAYywPfe05heaRkUhCYwqjmqsSL9bFZ 7g8kJt3TYe4mgXPiFUmNcEOhmwdbnDMcTYUJQ= Received: by 10.216.132.82 with SMTP id n60mr818638wei.35.1316183170059; Fri, 16 Sep 2011 07:26:10 -0700 (PDT) Received: from localhost.localdomain (93-34-199-31.ip51.fastwebnet.it. [93.34.199.31]) by mx.google.com with ESMTPS id ek13sm12701198wbb.23.2011.09.16.07.26.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 07:26:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 16 Sep 2011 16:25:39 +0200 Message-Id: <1316183152-5481-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1316183152-5481-1-git-send-email-pbonzini@redhat.com> References: <1316183152-5481-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.175 Cc: MORITA Kazutaka Subject: [Qemu-devel] [PATCH v2 02/15] add socket_set_block 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 Cc: MORITA Kazutaka Signed-off-by: Paolo Bonzini Reviewed-by: MORITA Kazutaka --- oslib-posix.c | 7 +++++++ oslib-win32.c | 6 ++++++ qemu_socket.h | 1 + 3 files changed, 14 insertions(+), 0 deletions(-) diff --git a/oslib-posix.c b/oslib-posix.c index a304fb0..dbc8ee8 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -103,6 +103,13 @@ void qemu_vfree(void *ptr) free(ptr); } +void socket_set_block(int fd) +{ + int f; + f = fcntl(fd, F_GETFL); + fcntl(fd, F_SETFL, f & ~O_NONBLOCK); +} + void socket_set_nonblock(int fd) { int f; diff --git a/oslib-win32.c b/oslib-win32.c index 5f0759f..5e3de7d 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -73,6 +73,12 @@ void qemu_vfree(void *ptr) VirtualFree(ptr, 0, MEM_RELEASE); } +void socket_set_block(int fd) +{ + unsigned long opt = 0; + ioctlsocket(fd, FIONBIO, &opt); +} + void socket_set_nonblock(int fd) { unsigned long opt = 1; diff --git a/qemu_socket.h b/qemu_socket.h index 180e4db..9e32fac 100644 --- a/qemu_socket.h +++ b/qemu_socket.h @@ -35,6 +35,7 @@ int inet_aton(const char *cp, struct in_addr *ia); /* misc helpers */ int qemu_socket(int domain, int type, int protocol); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +void socket_set_block(int fd); void socket_set_nonblock(int fd); int send_all(int fd, const void *buf, int len1);