From 0b7a0030acc27377b01e3afa41f672dc4d6a7561 Mon Sep 17 00:00:00 2001 From: dscho Date: Tue, 10 Jan 2006 14:07:58 +0000 Subject: rfbProcessEvents() has to iterate also over clients with sock < 0 to close them --- ChangeLog | 5 +++++ libvncserver/main.c | 4 +++- libvncserver/rfbserver.c | 18 ++++++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b59e07..0fb4066 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-10 Johannes E. Schindelin + * 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 * x11vnc: the big split. (and -afteraccept and -passwdfile read:..) * examples/pnmshow24.c: fix typo. diff --git a/libvncserver/main.c b/libvncserver/main.c index 352a00e..51f9f2f 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -904,6 +904,8 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec) rfbClientPtr cl,clPrev; struct timeval tv; rfbBool result=FALSE; + extern rfbClientIteratorPtr + rfbGetClientIteratorWithClosed(rfbScreenInfoPtr rfbScreen); if(usec<0) usec=screen->deferUpdateTime*1000; @@ -914,7 +916,7 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec) corbaCheckFds(screen); #endif - i = rfbGetClientIterator(screen); + i = rfbGetClientIteratorWithClosed(screen); cl=rfbClientIteratorHead(i); while(cl) { if (cl->sock >= 0 && !cl->onHold && FB_UPDATE_PENDING(cl) && diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index 7c620c8..8fab930 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -98,6 +98,7 @@ static MUTEX(rfbClientListMutex); struct rfbClientIterator { rfbClientPtr next; rfbScreenInfoPtr screen; + rfbBool closedToo; }; void @@ -120,6 +121,18 @@ rfbGetClientIterator(rfbScreenInfoPtr rfbScreen) (rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator)); i->next = NULL; 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; } @@ -152,8 +165,9 @@ rfbClientIteratorNext(rfbClientIteratorPtr i) } #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD - while(i->next && i->next->sock<0) - i->next = i->next->next; + if(!i->closedToo) + while(i->next && i->next->sock<0) + i->next = i->next->next; if(i->next) rfbIncrClientRef(i->next); #endif -- cgit v1.2.3