diff mbox

[2/4] qemu-socket: set passed fd non-blocking in socket_connect()

Message ID 1364314072-2474-3-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi March 26, 2013, 4:07 p.m. UTC
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(+)

Comments

Juan Quintela March 26, 2013, 4:33 p.m. UTC | #1
Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 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(+)
>
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index b6b78f5..298f6f2 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) {
> +            socket_set_nonblock(fd);
>              callback(fd, opaque);
>          }
>          break;

Reviewed-by: Juan Quintela <quintela@redhat.com>
Eric Blake March 26, 2013, 4:34 p.m. UTC | #2
On 03/26/2013 10:07 AM, Stefan Hajnoczi wrote:
> 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(+)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index b6b78f5..298f6f2 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) {
> +            socket_set_nonblock(fd);
>              callback(fd, opaque);
>          }
>          break;
>
diff mbox

Patch

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b6b78f5..298f6f2 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) {
+            socket_set_nonblock(fd);
             callback(fd, opaque);
         }
         break;