diff -ru xen-unstable-11405.orig/LibVNCServer-0.8.2/libvncserver/main.c xen-unstable-11405/LibVNCServer-0.8.2/libvncserver/main.c
--- xen-unstable-11405.orig/LibVNCServer-0.8.2/libvncserver/main.c 2006-05-28 16:38:26.000000000 -0400
+++ xen-unstable-11405/LibVNCServer-0.8.2/libvncserver/main.c 2006-09-12 14:23:09.000000000 -0400
@@ -454,13 +454,10 @@
updateRegion = sraRgnCreateRgn(cl->modifiedRegion);
haveUpdate = sraRgnAnd(updateRegion,cl->requestedRegion);
sraRgnDestroy(updateRegion);
- }
- UNLOCK(cl->updateMutex);
- if (!haveUpdate) {
WAIT(cl->updateCond, cl->updateMutex);
- UNLOCK(cl->updateMutex); /* we really needn't lock now. */
}
+ UNLOCK(cl->updateMutex);
}
/* OK, now, to save bandwidth, wait a little while for more
@@ -497,21 +494,25 @@
while (1) {
fd_set rfds, wfds, efds;
struct timeval tv;
- int n;
+ int n, sock;
+
+ LOCK(cl->updateMutex);
+ sock = cl->sock;
+ UNLOCK(cl->updateMutex);
FD_ZERO(&rfds);
- FD_SET(cl->sock, &rfds);
+ FD_SET(sock, &rfds);
FD_ZERO(&efds);
- FD_SET(cl->sock, &efds);
+ FD_SET(sock, &efds);
/* Are we transferring a file in the background? */
FD_ZERO(&wfds);
if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1))
- FD_SET(cl->sock, &wfds);
+ FD_SET(sock, &wfds);
tv.tv_sec = 60; /* 1 minute */
tv.tv_usec = 0;
- n = select(cl->sock + 1, &rfds, &wfds, &efds, &tv);
+ n = select(sock + 1, &rfds, &wfds, &efds, &tv);
if (n < 0) {
rfbLogPerror("ReadExact: select");
break;
@@ -523,16 +524,19 @@
}
/* We have some space on the transmit queue, send some data */
- if (FD_ISSET(cl->sock, &wfds))
+ if (FD_ISSET(sock, &wfds))
rfbSendFileTransferChunk(cl);
- if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
+ if (FD_ISSET(sock, &rfds) || FD_ISSET(sock, &efds))
rfbProcessClientMessage(cl);
- if (cl->sock == -1) {
- /* Client has disconnected. */
- break;
- }
+ LOCK(cl->updateMutex);
+ if (cl->sock == -1) {
+ UNLOCK(cl->updateMutex);
+ /* Client has disconnected. */
+ break;
+ }
+ UNLOCK(cl->updateMutex);
}
/* Get rid of the output thread. */
diff -ru xen-unstable-11405.orig/LibVNCServer-0.8.2/libvncserver/rfbserver.c xen-unstable-11405/LibVNCServer-0.8.2/libvncserver/rfbserver.c
--- xen-unstable-11405.orig/LibVNCServer-0.8.2/libvncserver/rfbserver.c 2006-06-05 14:50:45.000000000 -0400
+++ xen-unstable-11405/LibVNCServer-0.8.2/libvncserver/rfbserver.c 2006-09-12 13:02:06.000000000 -0400
@@ -492,9 +492,9 @@
do {
LOCK(cl->refCountMutex);
i=cl->refCount;
- UNLOCK(cl->refCountMutex);
if(i>0)
WAIT(cl->deleteCond,cl->refCountMutex);
+ UNLOCK(cl->refCountMutex);
} while(i>0);
}
#endif