From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1gTy-0003mf-HI for qemu-devel@nongnu.org; Thu, 08 Sep 2011 11:25:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1gTt-0000uC-BN for qemu-devel@nongnu.org; Thu, 08 Sep 2011 11:25:38 -0400 Received: from mail-ew0-f45.google.com ([209.85.215.45]:51390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1gTs-0000tp-I1 for qemu-devel@nongnu.org; Thu, 08 Sep 2011 11:25:33 -0400 Received: by ewy24 with SMTP id 24so460535ewy.4 for ; Thu, 08 Sep 2011 08:25:31 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 8 Sep 2011 17:25:01 +0200 Message-Id: <1315495505-28906-9-git-send-email-pbonzini@redhat.com> In-Reply-To: <1315495505-28906-1-git-send-email-pbonzini@redhat.com> References: <1315495505-28906-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 08/12] add socket_set_block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: MORITA Kazutaka 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 196099c..e13e6d4 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -91,6 +91,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); -- 1.7.6