summaryrefslogtreecommitdiffstats
path: root/libvncserver/main.c
diff options
context:
space:
mode:
authordscho <dscho>2005-05-07 13:33:09 +0000
committerdscho <dscho>2005-05-07 13:33:09 +0000
commit34f714bcdc3e2d7a21a9179357dc93f2561301c8 (patch)
tree850d98f9535bd0e1fa10faff773e5069bbefbd40 /libvncserver/main.c
parent1bb36df34ea25a3379b5232154a55e4da489ab60 (diff)
downloadlibtdevnc-34f714bcdc3e2d7a21a9179357dc93f2561301c8.tar.gz
libtdevnc-34f714bcdc3e2d7a21a9179357dc93f2561301c8.zip
socketInitDone -> socketState
Diffstat (limited to 'libvncserver/main.c')
-rw-r--r--libvncserver/main.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/libvncserver/main.c b/libvncserver/main.c
index 529bf2a..d2dc69f 100644
--- a/libvncserver/main.c
+++ b/libvncserver/main.c
@@ -543,7 +543,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
screen->clientHead=0;
screen->pointerClient=0;
screen->port=5900;
- screen->socketInitDone=FALSE;
+ screen->socketState=RFB_SOCKET_INIT;
screen->inetdInitDone = FALSE;
screen->inetdSock=-1;
@@ -729,7 +729,7 @@ void rfbScreenCleanup(rfbScreenInfoPtr screen)
FREE_IF(colourMap.data.bytes);
FREE_IF(underCursorBuffer);
TINI_MUTEX(screen->cursorMutex);
- if(screen->cursor)
+ if(screen->cursor && screen->cursor->cleanup)
rfbFreeCursor(screen->cursor);
free(screen);
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
@@ -751,6 +751,20 @@ void rfbInitServer(rfbScreenInfoPtr screen)
#endif
}
+void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
+ if(disconnectClients) {
+ rfbClientPtr cl;
+ rfbClientIteratorPtr iter = rfbGetClientIterator(screen);
+ while( (cl = rfbClientIteratorNext(iter)) )
+ if (cl->sock > -1)
+ /* we don't care about maxfd here, because the server goes away */
+ rfbCloseClient(cl);
+ }
+
+ rfbShutdownSockets(screen);
+ rfbHttpShutdownSockets(screen);
+}
+
#ifndef LIBVNCSERVER_HAVE_GETTIMEOFDAY
#include <fcntl.h>
#include <conio.h>
@@ -820,6 +834,10 @@ rfbProcessEvents(rfbScreenInfoPtr screen,long usec)
return result;
}
+rfbBool rfbIsActive(rfbScreenInfoPtr screenInfo) {
+ return screenInfo->socketState!=RFB_SOCKET_SHUTDOWN || screenInfo->clientHead!=NULL;
+}
+
void rfbRunEventLoop(rfbScreenInfoPtr screen, long usec, rfbBool runInBackground)
{
if(runInBackground) {
@@ -839,6 +857,6 @@ void rfbRunEventLoop(rfbScreenInfoPtr screen, long usec, rfbBool runInBackground
if(usec<0)
usec=screen->deferUpdateTime*1000;
- while(1)
+ while(rfbIsActive(screen))
rfbProcessEvents(screen,usec);
}