aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/service
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-09 22:35:22 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-09 22:37:13 +0100
commit5ecc7a86e659390fa3c975aca72849dedf1412f6 (patch)
treec90c52ee2dbcb0811ce6714e03933eafba586bcd /service
parentinstaller: add basic wix skeleton (diff)
downloadwireguard-windows-5ecc7a86e659390fa3c975aca72849dedf1412f6.tar.xz
wireguard-windows-5ecc7a86e659390fa3c975aca72849dedf1412f6.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. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'service')
-rw-r--r--service/tunneltracker.go9
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 {