Patchwork [v2,3/4] qemu-socket: set passed fd non-blocking in socket_connect()

login
register
mail settings
Submitter Stefan Hajnoczi
Date March 27, 2013, 9:10 a.m.
Message ID <1364375446-24180-4-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/231616/
State New
Headers show

Comments

Stefan Hajnoczi - March 27, 2013, 9:10 a.m.
socket_connect() sets non-blocking on TCP or UNIX domain sockets if a
callback function is passed.  Do the same for file descriptor passing,
otherwise we could unexpectedly be using a blocking file descriptor.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 util/qemu-sockets.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b632a74..94581aa 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -910,6 +910,7 @@  int socket_connect(SocketAddress *addr, Error **errp,
     case SOCKET_ADDRESS_KIND_FD:
         fd = monitor_get_fd(cur_mon, addr->fd->str, errp);
         if (callback) {
+            qemu_set_nonblock(fd);
             callback(fd, opaque);
         }
         break;