Commit d3bb5fb6 authored by dscho's avatar dscho

fixed a bug that prevented the first connection to be closed

parent 2a48679c
...@@ -750,6 +750,9 @@ void gettimeofday(struct timeval* tv,char* dummy) ...@@ -750,6 +750,9 @@ void gettimeofday(struct timeval* tv,char* dummy)
} }
#endif #endif
/* defined in rfbserver.c, but kind of "private" */
rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i);
void void
rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec) rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
{ {
...@@ -767,7 +770,7 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec) ...@@ -767,7 +770,7 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
#endif #endif
i = rfbGetClientIterator(rfbScreen); i = rfbGetClientIterator(rfbScreen);
cl=rfbClientIteratorNext(i); cl=rfbClientIteratorHead(i);
while(cl) { while(cl) {
if (cl->sock >= 0 && !cl->onHold && FB_UPDATE_PENDING(cl) && if (cl->sock >= 0 && !cl->onHold && FB_UPDATE_PENDING(cl) &&
!sraRgnEmpty(cl->requestedRegion)) { !sraRgnEmpty(cl->requestedRegion)) {
......
...@@ -118,6 +118,21 @@ rfbGetClientIterator(rfbScreenInfoPtr rfbScreen) ...@@ -118,6 +118,21 @@ rfbGetClientIterator(rfbScreenInfoPtr rfbScreen)
return i; return i;
} }
rfbClientPtr
rfbClientIteratorHead(rfbClientIteratorPtr i)
{
#ifdef HAVE_LIBPTHREAD
if(i->next != 0) {
rfbDecrClientRef(i->next);
rfbIncrClientRef(i->screen->rfbClientHead);
}
#endif
LOCK(rfbClientListMutex);
i->next = i->screen->rfbClientHead;
UNLOCK(rfbClientListMutex);
return i->next;
}
rfbClientPtr rfbClientPtr
rfbClientIteratorNext(rfbClientIteratorPtr i) rfbClientIteratorNext(rfbClientIteratorPtr i)
{ {
...@@ -396,7 +411,8 @@ rfbClientConnectionGone(cl) ...@@ -396,7 +411,8 @@ rfbClientConnectionGone(cl)
LOCK(cl->refCountMutex); LOCK(cl->refCountMutex);
if(cl->refCount) { if(cl->refCount) {
UNLOCK(cl->refCountMutex); UNLOCK(cl->refCountMutex);
WAIT(cl->deleteCond,cl->refCountMutex); if(cl->screen->backgroundLoop != FALSE)
WAIT(cl->deleteCond,cl->refCountMutex);
} else { } else {
UNLOCK(cl->refCountMutex); UNLOCK(cl->refCountMutex);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment