Patchwork [v2,02/15] add socket_set_block

login
register
mail settings
Submitter Paolo Bonzini
Date Sept. 16, 2011, 2:25 p.m.
Message ID <1316183152-5481-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/114929/
State New
Headers show

Comments

Paolo Bonzini - Sept. 16, 2011, 2:25 p.m.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 oslib-posix.c |    7 +++++++
 oslib-win32.c |    6 ++++++
 qemu_socket.h |    1 +
 3 files changed, 14 insertions(+), 0 deletions(-)
MORITA Kazutaka - Sept. 17, 2011, 5:33 a.m.
At Fri, 16 Sep 2011 16:25:39 +0200,
Paolo Bonzini wrote:
> 
> Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  oslib-posix.c |    7 +++++++
>  oslib-win32.c |    6 ++++++
>  qemu_socket.h |    1 +
>  3 files changed, 14 insertions(+), 0 deletions(-)

Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>

Patch

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);