Skip to content

Commit

Permalink
VNCConn: let Shutdown() close the socket before thread joining
Browse files Browse the repository at this point in the history
This lets us break any connection so that vnc thread moves over
blocking calls.

re #145
  • Loading branch information
bk138 committed Feb 19, 2025
1 parent f83634d commit 7bee9c4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/VNCConn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,22 +1223,24 @@ void VNCConn::Shutdown()

mutex_auth.Unlock();

// break any connection so that vnc thread moves over blocking calls
if(cl) {
wxLogDebug(wxT( "VNCConn %p: Shutdown() closing connection"), this);
rfbCloseSocket(cl->sock);
}

// end vnc thread and wait for it to get done
if(GetThread() && GetThread()->IsRunning())
{
wxLogDebug(wxT( "VNCConn %p: Shutdown() before vncthread delete"), this);

GetThread()->Delete(); // this blocks if thread is joinable, i.e. on stack
wxLogDebug(wxT("VNCConn %p: Shutdown() after vncthread delete"), this);
}

if(cl)
{
wxLogDebug(wxT( "VNCConn %p: Shutdown() closing connection"), this);
#ifdef __WIN32__
closesocket(cl->sock);
#else
close(cl->sock);
#endif

// then, clean up client
if(cl) {
wxLogDebug(wxT( "VNCConn %p: Shutdown() cleaning up client"), this);
// this one was strdup'ed before
if(!cl->listenSpecified)
free((void*)cl->appData.encodingsString);
Expand Down

0 comments on commit 7bee9c4

Please sign in to comment.