Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2115?usp=email
to review the following change.
Change subject: openvpnserv: let workers clean up when stopping on error
......................................................................
openvpnserv: let workers clean up when stopping on error
If ConnectNamedPipe() or WaitForMultipleObjects() failed, the service
stopped without waiting for its worker threads, so routes and DNS
settings of running connections were left behind. The service also
reported a wrong exit code.
Signal the workers and wait for them like on a regular stop, and
report the actual error.
Change-Id: I24744f5bc1b036e8abb9c1ec3cca13124aead441
Signed-off-by: Heiko Hund <[email protected]>
---
M src/openvpnserv/interactive.c
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/2115/1
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 37e8667..2def870 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -4077,7 +4077,7 @@
}
else if (connect_error != ERROR_IO_PENDING)
{
- MsgToEventLog(M_SYSERR, L"Could not connect pipe");
+ error = MsgToEventLog(M_SYSERR, L"Could not connect pipe");
break;
}
}
@@ -4146,10 +4146,7 @@
CancelIo(pipe);
if (error == WAIT_FAILED)
{
- MsgToEventLog(M_SYSERR, L"WaitForMultipleObjects failed");
- SetEvent(exit_event);
- /* Give some time for worker threads to exit and then
terminate */
- Sleep(1000);
+ error = MsgToEventLog(M_SYSERR, L"WaitForMultipleObjects
failed");
break;
}
if (!threads)
@@ -4168,6 +4165,20 @@
}
}
+ /* Let worker threads undo their changes before stopping */
+ if (threads)
+ {
+ status.dwCurrentState = SERVICE_STOP_PENDING;
+ ReportStatusToSCMgr(service, &status);
+ SetEvent(exit_event);
+ /* handles[0] is io_event, the rest are the worker threads */
+ if (WaitForMultipleObjects(handle_count - 1, handles + 1, TRUE,
INFINITE) == WAIT_FAILED)
+ {
+ Sleep(5000); /* if we can't wait, give some time */
+ }
+ }
+ CloseHandleEx(&pipe);
+
out:
FreeWaitHandles(handles);
CloseHandleEx(&io_event);
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2115?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I24744f5bc1b036e8abb9c1ec3cca13124aead441
Gerrit-Change-Number: 2115
Gerrit-PatchSet: 1
Gerrit-Owner: Heiko Hund <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel