From 4da78f6e703a702421366d658bd5ac73443b55b8 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Thu, 28 Jul 2022 22:55:59 -0400 Subject: [PATCH] Change state to connecting/resuming before return from StartOpenVPN - Early state change from the main thread makes it synchronous and thus easier to wait on the connection to complete when started programmatically. Made use of in Connect() in the PLAP implementation that follows. Does not affect on the current mode of operation. Signed-off-by: Selva Nair --- openvpn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openvpn.c b/openvpn.c index 70a2dd6..b052abe 100644 --- a/openvpn.c +++ b/openvpn.c @@ -2102,8 +2102,6 @@ ThreadOpenVPNStatus(void *p) _tcsncpy(conn_name, c->config_file, _countof(conn_name)); conn_name[_tcslen(conn_name) - _tcslen(o.ext_string) - 1] = _T('\0'); - c->state = (c->state == suspended || c->state == detached) ? resuming : connecting; - /* Create and Show Status Dialog */ c->hwndStatus = CreateLocalizedDialogParam(ID_DLG_STATUS, StatusDialogFunc, (LPARAM) c); if (!c->hwndStatus) @@ -2336,6 +2334,8 @@ StartOpenVPN(connection_t *c) return false; } + c->state = (c->state == suspended || c->state == detached) ? resuming : connecting; + /* Start the status dialog thread */ ResumeThread(hThread);