From patchwork Wed Oct 5 07:17:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 117764 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 3AC9BB6F8B for ; Wed, 5 Oct 2011 19:24:17 +1100 (EST) Received: from localhost ([::1]:46833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBLkO-0000Ys-TM for incoming@patchwork.ozlabs.org; Wed, 05 Oct 2011 03:18:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:33108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBLjk-00070F-K3 for qemu-devel@nongnu.org; Wed, 05 Oct 2011 03:17:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBLjj-0006Es-LA for qemu-devel@nongnu.org; Wed, 05 Oct 2011 03:17:52 -0400 Received: from mail-ww0-f53.google.com ([74.125.82.53]:42322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBLjj-0006EG-Gf for qemu-devel@nongnu.org; Wed, 05 Oct 2011 03:17:51 -0400 Received: by mail-ww0-f53.google.com with SMTP id 14so1759680wwg.10 for ; Wed, 05 Oct 2011 00:17:51 -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=XwiofHhPWXjWyEohdFsJLo9vW792G9WUS1JbkE/4K/GEPEsx5zrUmxjPksMC0Uevfn UR4pN+VurWh+z5JCrTr32XoBD856/iK2/Wu5MXRmTBH7hJtWQ6Dc1A3AfEGMcCnveuhW CU7NplqoOvl/95nEJWgZKL99EAkI9gUUnCCxs= Received: by 10.227.37.155 with SMTP id x27mr2700288wbd.54.1317799071014; Wed, 05 Oct 2011 00:17:51 -0700 (PDT) Received: from localhost.localdomain (93-34-218-143.ip51.fastwebnet.it. [93.34.218.143]) by mx.google.com with ESMTPS id p2sm1192306wbo.17.2011.10.05.00.17.50 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Oct 2011 00:17:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 5 Oct 2011 09:17:32 +0200 Message-Id: <1317799065-29668-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1317799065-29668-1-git-send-email-pbonzini@redhat.com> References: <1317799065-29668-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.53 Cc: MORITA Kazutaka Subject: [Qemu-devel] [PATCH v3 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 --- 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);