add socket_set_block

Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Paolo Bonzini 2011-10-05 09:17:32 +02:00 committed by Kevin Wolf
parent d8716b41b9
commit 154b9a0cbd
3 changed files with 14 additions and 0 deletions

View File

@ -103,6 +103,13 @@ void qemu_vfree(void *ptr)
free(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) void socket_set_nonblock(int fd)
{ {
int f; int f;

View File

@ -73,6 +73,12 @@ void qemu_vfree(void *ptr)
VirtualFree(ptr, 0, MEM_RELEASE); 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) void socket_set_nonblock(int fd)
{ {
unsigned long opt = 1; unsigned long opt = 1;

View File

@ -35,6 +35,7 @@ int inet_aton(const char *cp, struct in_addr *ia);
/* misc helpers */ /* misc helpers */
int qemu_socket(int domain, int type, int protocol); int qemu_socket(int domain, int type, int protocol);
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
void socket_set_block(int fd);
void socket_set_nonblock(int fd); void socket_set_nonblock(int fd);
int send_all(int fd, const void *buf, int len1); int send_all(int fd, const void *buf, int len1);