From: Paolo Bonzini Date: Wed, 5 Oct 2011 07:17:32 +0000 (+0200) Subject: add socket_set_block X-Git-Tag: v1.0-rc0~55^2~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=154b9a0cbd67be53afcb45ae84a240add8c6cb67;p=thirdparty%2Fqemu.git add socket_set_block Cc: MORITA Kazutaka Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- diff --git a/oslib-posix.c b/oslib-posix.c index a304fb0f536..dbc8ee89603 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 5f0759ffc48..5e3de7dc8a5 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 180e4dbd9b5..9e32fac6510 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);