From a5f8d3a3109b545219ad5b34859f1b7d3b8b6d56 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Thu, 18 Nov 2010 14:36:52 +0100 Subject: [PATCH] libvncserver: fix endless loop when server closed client in threaded mode. Signed-off-by: Christian Beier --- libvncserver/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libvncserver/main.c b/libvncserver/main.c index 5332e2d..b128581 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -517,6 +517,11 @@ clientInput(void *data) struct timeval tv; int n; + if (cl->sock == -1) { + /* Client has disconnected. */ + break; + } + FD_ZERO(&rfds); FD_SET(cl->sock, &rfds); FD_ZERO(&efds); @@ -546,11 +551,6 @@ clientInput(void *data) if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds)) rfbProcessClientMessage(cl); - - if (cl->sock == -1) { - /* Client has disconnected. */ - break; - } } /* Get rid of the output thread. */