diff mbox

: VNC: set listener socket to non-blocking mode

Message ID 1287677919.12843.4383.camel@qabil.uk.xensource.com
State New
Headers show

Commit Message

Gianni Tedesco Oct. 21, 2010, 4:18 p.m. UTC
This prevents qemu from hanging waiting for a client to connect. I have
reproduced this when doing a loadvm but it may be a more general problem
in that poll/accept may race if a client aborts the connection with a
RST before the accept has completed. In either case the fix seems
harmless.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>

Comments

Anthony Liguori Oct. 21, 2010, 4:44 p.m. UTC | #1
On 10/21/2010 11:18 AM, Gianni Tedesco wrote:
> This prevents qemu from hanging waiting for a client to connect. I have
> reproduced this when doing a loadvm but it may be a more general problem
> in that poll/accept may race if a client aborts the connection with a
> RST before the accept has completed. In either case the fix seems
> harmless.
>
> Signed-off-by: Gianni Tedesco<gianni.tedesco@citrix.com>
>    

I'd feel a little better with explicit error handling in the accept() 
path and a comment explaining why this was necessary.

But otherwise, nice catch!

Regards,

Anthony Liguori

> diff --git a/ui/vnc.c b/ui/vnc.c
> index 864342e..172b988 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -2736,5 +2736,6 @@ int vnc_display_open(DisplayState *ds, const char *display)
>               vs->display = dpy;
>           }
>       }
> +    socket_set_nonblock(vs->lsock);
>       return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs);
>   }
>
>
>
>
diff mbox

Patch

diff --git a/ui/vnc.c b/ui/vnc.c
index 864342e..172b988 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2736,5 +2736,6 @@  int vnc_display_open(DisplayState *ds, const char *display)
             vs->display = dpy;
         }
     }
+    socket_set_nonblock(vs->lsock);
     return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs);
 }