summaryrefslogtreecommitdiffstats
path: root/sockets.c
diff options
context:
space:
mode:
authordscho <dscho>2002-06-13 17:41:40 +0000
committerdscho <dscho>2002-06-13 17:41:40 +0000
commit131ede28a74bb18037f5bfbbe1f9ac8f26546544 (patch)
tree780775dd3bb5c9c5db82e72d49936216bd928f9c /sockets.c
parentaf41bea661790da0f47089f387f58ffec2c875ee (diff)
downloadlibtdevnc-131ede28a74bb18037f5bfbbe1f9ac8f26546544.tar.gz
libtdevnc-131ede28a74bb18037f5bfbbe1f9ac8f26546544.zip
pthread fix
Diffstat (limited to 'sockets.c')
-rw-r--r--sockets.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sockets.c b/sockets.c
index 350ff44..e27ddc6 100644
--- a/sockets.c
+++ b/sockets.c
@@ -309,12 +309,18 @@ rfbCloseClient(cl)
rfbClientPtr cl;
{
LOCK(cl->updateMutex);
- if (cl->sock != -1) {
- FD_CLR(cl->sock,&(cl->screen->allFds));
- shutdown(cl->sock,SHUT_RDWR);
- close(cl->sock);
- cl->sock = -1;
- }
+#ifdef HAVE_PTHREADS
+ if (cl->sock != -1)
+#endif
+ {
+ FD_CLR(cl->sock,&(cl->screen->allFds));
+ if(cl->sock==cl->screen->maxFd)
+ while(!FD_ISSET(cl->screen->maxFd,&(cl->screen->allFds)))
+ cl->screen->maxFd--;
+ shutdown(cl->sock,SHUT_RDWR);
+ close(cl->sock);
+ cl->sock = -1;
+ }
TSIGNAL(cl->updateCond);
UNLOCK(cl->updateMutex);
}