Commit 0b7a0030 authored by dscho's avatar dscho

rfbProcessEvents() has to iterate also over clients with sock < 0 to close them

parent 71f2ec79
2006-01-10 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* libvncserver/{main.c,rfbserver.c}: fix timely closing of clients;
the client iterator in rfbProcessEvents() has to iterate also
over clients whose sock < 0. Noticed by Karl.
2006-01-08 Karl Runge <runge@karlrunge.com> 2006-01-08 Karl Runge <runge@karlrunge.com>
* x11vnc: the big split. (and -afteraccept and -passwdfile read:..) * x11vnc: the big split. (and -afteraccept and -passwdfile read:..)
* examples/pnmshow24.c: fix typo. * examples/pnmshow24.c: fix typo.
......
...@@ -904,6 +904,8 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec) ...@@ -904,6 +904,8 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec)
rfbClientPtr cl,clPrev; rfbClientPtr cl,clPrev;
struct timeval tv; struct timeval tv;
rfbBool result=FALSE; rfbBool result=FALSE;
extern rfbClientIteratorPtr
rfbGetClientIteratorWithClosed(rfbScreenInfoPtr rfbScreen);
if(usec<0) if(usec<0)
usec=screen->deferUpdateTime*1000; usec=screen->deferUpdateTime*1000;
...@@ -914,7 +916,7 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec) ...@@ -914,7 +916,7 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec)
corbaCheckFds(screen); corbaCheckFds(screen);
#endif #endif
i = rfbGetClientIterator(screen); i = rfbGetClientIteratorWithClosed(screen);
cl=rfbClientIteratorHead(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) &&
......
...@@ -98,6 +98,7 @@ static MUTEX(rfbClientListMutex); ...@@ -98,6 +98,7 @@ static MUTEX(rfbClientListMutex);
struct rfbClientIterator { struct rfbClientIterator {
rfbClientPtr next; rfbClientPtr next;
rfbScreenInfoPtr screen; rfbScreenInfoPtr screen;
rfbBool closedToo;
}; };
void void
...@@ -120,6 +121,18 @@ rfbGetClientIterator(rfbScreenInfoPtr rfbScreen) ...@@ -120,6 +121,18 @@ rfbGetClientIterator(rfbScreenInfoPtr rfbScreen)
(rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator)); (rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator));
i->next = NULL; i->next = NULL;
i->screen = rfbScreen; i->screen = rfbScreen;
i->closedToo = FALSE;
return i;
}
rfbClientIteratorPtr
rfbGetClientIteratorWithClosed(rfbScreenInfoPtr rfbScreen)
{
rfbClientIteratorPtr i =
(rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator));
i->next = NULL;
i->screen = rfbScreen;
i->closedToo = TRUE;
return i; return i;
} }
...@@ -152,8 +165,9 @@ rfbClientIteratorNext(rfbClientIteratorPtr i) ...@@ -152,8 +165,9 @@ rfbClientIteratorNext(rfbClientIteratorPtr i)
} }
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
while(i->next && i->next->sock<0) if(!i->closedToo)
i->next = i->next->next; while(i->next && i->next->sock<0)
i->next = i->next->next;
if(i->next) if(i->next)
rfbIncrClientRef(i->next); rfbIncrClientRef(i->next);
#endif #endif
......
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