diff options
author | Pierre Ossman <ossman@cendio.se> | 2018-09-29 11:24:19 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2018-11-09 17:25:23 +0100 |
commit | 10688efcf759f24e83814f9e12a1275296b07a4c (patch) | |
tree | 51d46d026e8cc9c04aae739e52582c6566c45112 /win | |
parent | f43137c61bd19fd3a7a51833c9eb9bb9f890a904 (diff) | |
download | tigervnc-10688efcf759f24e83814f9e12a1275296b07a4c.tar.gz tigervnc-10688efcf759f24e83814f9e12a1275296b07a4c.zip |
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.
Diffstat (limited to 'win')
-rw-r--r-- | win/rfb_win32/SDisplay.cxx | 6 | ||||
-rw-r--r-- | win/rfb_win32/SDisplay.h | 4 | ||||
-rw-r--r-- | win/winvnc/VNCServerWin32.cxx | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx index afb72ad7..2cedc4a8 100644 --- a/win/rfb_win32/SDisplay.cxx +++ b/win/rfb_win32/SDisplay.cxx @@ -71,6 +71,7 @@ SDisplay::SDisplay() 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 @@ void SDisplay::stop() 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 76ddf50b..6dbfabbc 100644 --- a/win/rfb_win32/SDisplay.h +++ b/win/rfb_win32/SDisplay.h @@ -72,6 +72,7 @@ namespace rfb { 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 @@ namespace rfb { // -=- 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 @@ namespace rfb { // -=- 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; diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx index 03b1bca7..e0014495 100644 --- a/win/winvnc/VNCServerWin32.cxx +++ b/win/winvnc/VNCServerWin32.cxx @@ -76,6 +76,7 @@ VNCServerWin32::VNCServerWin32() // Register the desktop's event to be handled sockMgr.addEvent(desktop.getUpdateEvent(), &desktop); + sockMgr.addEvent(desktop.getTerminateEvent(), this); // Register the queued command event to be handled sockMgr.addEvent(commandEvent, this); @@ -335,7 +336,8 @@ void VNCServerWin32::processEvent(HANDLE event_) { command = NoCommand; commandSig->signal(); } - } else if (event_ == sessionEvent.h) { + } else if ((event_ == sessionEvent.h) || + (event_ == desktop.getTerminateEvent())) { stop(); } } |