diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-09 22:35:22 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-09 22:37:13 +0100 |
commit | b5ac9cad923133ace1e13f3bba1f75efc75b3dd3 (patch) | |
tree | c90c52ee2dbcb0811ce6714e03933eafba586bcd /service | |
parent | installer: add basic wix skeleton (diff) | |
download | wireguard-windows-b5ac9cad923133ace1e13f3bba1f75efc75b3dd3.tar.xz wireguard-windows-b5ac9cad923133ace1e13f3bba1f75efc75b3dd3.zip |
tunneltracker: account for windows 7 statemachine bug
Windows 7 will transition to stopping after it has already triggered
stopped, so keep track of that and filter it out.
Diffstat (limited to 'service')
-rw-r--r-- | service/tunneltracker.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/service/tunneltracker.go b/service/tunneltracker.go index 96d0f6e3..89de0c38 100644 --- a/service/tunneltracker.go +++ b/service/tunneltracker.go @@ -90,6 +90,10 @@ func trackTunnelService(tunnelName string, svc *mgr.Service) { notifyCallback: serviceTrackerCallbackPtr, } defer svc.Close() + + // This hasStopped ugliness is because Windows 7 will send a STOP_PENDING after it has already sent a STOPPED + hasStopped := false + for { notifier.context = 0 err := notifyServiceStatusChange(svc.Handle, serviceNotifications, uintptr(unsafe.Pointer(notifier))) @@ -105,12 +109,15 @@ func trackTunnelService(tunnelName string, svc *mgr.Service) { state = TunnelDeleting } else if notifier.notificationTriggered&serviceNotify_STOPPED != 0 { state = TunnelStopped - } else if notifier.notificationTriggered&serviceNotify_STOP_PENDING != 0 { + hasStopped = true + } else if notifier.notificationTriggered&serviceNotify_STOP_PENDING != 0 && hasStopped { state = TunnelStopping } else if notifier.notificationTriggered&serviceNotify_RUNNING != 0 { state = TunnelStarted + hasStopped = false } else if notifier.notificationTriggered&serviceNotify_START_PENDING != 0 { state = TunnelStarting + hasStopped = false } IPCServerNotifyTunnelChange(tunnelName, state) if state == TunnelDeleting { |