@@ -290,10 +290,6 @@ wxThread::ExitCode VNCConn::Entry()
290290
291291 if (!rfbClientConnect (cl)) {
292292 err.Printf (_ (" Failure connecting to server at %s:%d!" ), host, port);
293- // There might be the case that the SSH tunnel got setup alright, but connecting to the VNC server failed.
294- // In this case we have to dispose of the tunnel explicitly here.
295- ssh_tunnel_close (ssh_tunnel);
296- ssh_tunnel = NULL ;
297293 if (thread_shutdown) {
298294 wxLogDebug (" VNCConn %p: rfbClientConnect() canceled." , this );
299295 thread_post_init_notify (InitState::CONNECT_CANCEL);
@@ -307,10 +303,6 @@ wxThread::ExitCode VNCConn::Entry()
307303 wxLogDebug (" VNCConn %p: rfbClientConnect() succeeded." , this );
308304 thread_post_init_notify (InitState::CONNECT_SUCCESS);
309305 if (!rfbClientInitialise (cl)) {
310- // There might be the case that the SSH tunnel got setup alright, but auth at the VNC server failed.
311- // In this case we have to dispose of the tunnel explicitly here.
312- ssh_tunnel_close (ssh_tunnel);
313- ssh_tunnel = NULL ;
314306 err.Printf (_ (" Failure connecting to server at %s:%d!" ), host, port);
315307 if (thread_shutdown) {
316308 wxLogDebug (" VNCConn %p: rfbClientInitialise() canceled." , this );
@@ -1276,15 +1268,18 @@ void VNCConn::Shutdown()
12761268
12771269 mutex_auth.Unlock ();
12781270
1271+ if (ssh_tunnel) {
1272+ wxLogDebug (wxT ( " VNCConn %p: Shutdown() closing SSH tunnel" ), this );
1273+ ssh_tunnel_close (ssh_tunnel);
1274+ ssh_tunnel = NULL ;
1275+ }
1276+
12791277 // break any connection so that vnc thread moves over blocking calls
12801278 if (cl) {
12811279 wxLogDebug (wxT ( " VNCConn %p: Shutdown() closing connection" ), this );
12821280 rfbCloseSocket (cl->sock );
12831281 }
12841282
1285- ssh_tunnel_close (ssh_tunnel);
1286- ssh_tunnel = NULL ;
1287-
12881283 // end vnc thread and wait for it to get done
12891284 if (GetThread () && GetThread ()->IsRunning ())
12901285 {
0 commit comments