Properly terminate server on timeouts
Do a proper cleanup when one of the termination timeouts trigger
rather than just exiting on the spot. This makes sure we don't leave
stray stuff around, e.g. unix socket files.
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index afb72ad..2cedc4a 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -71,6 +71,7 @@
statusLocation(0), queryConnectionHandler(0), ledState(0)
{
updateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
+ terminateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
}
SDisplay::~SDisplay()
@@ -140,6 +141,11 @@
if (statusLocation) *statusLocation = false;
}
+void SDisplay::terminate()
+{
+ SetEvent(terminateEvent);
+}
+
void SDisplay::queryConnection(network::Socket* sock,
const char* userName)
diff --git a/win/rfb_win32/SDisplay.h b/win/rfb_win32/SDisplay.h
index 76ddf50..6dbfabb 100644
--- a/win/rfb_win32/SDisplay.h
+++ b/win/rfb_win32/SDisplay.h
@@ -72,6 +72,7 @@
virtual void start(VNCServer* vs);
virtual void stop();
+ virtual void terminate();
virtual void queryConnection(network::Socket* sock,
const char* userName);
virtual void pointerEvent(const Point& pos, int buttonmask);
@@ -89,6 +90,7 @@
// -=- EventHandler interface
HANDLE getUpdateEvent() {return updateEvent;}
+ HANDLE getTerminateEvent() {return terminateEvent;}
virtual void processEvent(HANDLE event);
// -=- Notification of whether or not SDisplay is started
@@ -161,6 +163,8 @@
// -=- Event signalled to trigger an update to be flushed
Handle updateEvent;
+ // -=- Event signalled to terminate the server
+ Handle terminateEvent;
// -=- Where to write the active/inactive indicator to
bool* statusLocation;