mirror of https://github.com/OpenVPN/openvpn-gui
Do not start a connection when a previous thread has not fully exited
When openvpn exits due to error, the GUI pops up a modal dialog and waits on user to click OK before cleaning up resources and closing the status window. During this phase if the user clicks "connect" from the tray menu, a new thread is started overwriiting several handles in the connection struct. Fix: Refuse to start a connection when previous status thread is still active. Instead, bring the exisiting status window to fore-ground. Also make the modal dialog a child of the status window for better visibility. Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/86/head
parent
fcd0efa479
commit
ad58766f52
15
openvpn.c
15
openvpn.c
|
@ -474,7 +474,8 @@ OnStop(connection_t *c, UNUSED char *msg)
|
|||
SetForegroundWindow(c->hwndStatus);
|
||||
ShowWindow(c->hwndStatus, SW_SHOW);
|
||||
}
|
||||
ShowLocalizedMsg(IDS_NFO_CONN_TERMINATED, c->config_name);
|
||||
MessageBox(c->hwndStatus, LoadLocalizedString(IDS_NFO_CONN_TERMINATED, c->config_file),
|
||||
_T(PACKAGE_NAME), MB_OK);
|
||||
SendMessage(c->hwndStatus, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
|
||||
|
@ -501,7 +502,7 @@ OnStop(connection_t *c, UNUSED char *msg)
|
|||
SetForegroundWindow(c->hwndStatus);
|
||||
ShowWindow(c->hwndStatus, SW_SHOW);
|
||||
}
|
||||
ShowLocalizedMsg(msg_id, msg_xtra);
|
||||
MessageBox(c->hwndStatus, LoadLocalizedString(msg_id, msg_xtra), _T(PACKAGE_NAME), MB_OK);
|
||||
SendMessage(c->hwndStatus, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
|
||||
|
@ -1045,6 +1046,7 @@ ThreadOpenVPNStatus(void *p)
|
|||
|
||||
/* release handles etc.*/
|
||||
Cleanup (c);
|
||||
c->hwndStatus = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1089,6 +1091,15 @@ StartOpenVPN(connection_t *c)
|
|||
|
||||
CLEAR(c->ip);
|
||||
|
||||
if (c->hwndStatus)
|
||||
{
|
||||
PrintDebug(L"Connection request when previous status window is still open -- ignored");
|
||||
WriteStatusLog(c, L"OpenVPN GUI> ",
|
||||
L"Complete the pending dialog before starting a new connection", false);
|
||||
SetForegroundWindow(c->hwndStatus);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RunPreconnectScript(c);
|
||||
|
||||
/* Create thread to show the connection's status dialog */
|
||||
|
|
Loading…
Reference in New Issue