summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-01-09 14:35:35 +0100
committerDavid Lönnhager <david.l@mullvad.net>2020-01-09 15:50:40 +0100
commitd7061bb40f7b039a1508a3d6a6b514aa3defe33b (patch)
tree6ce35a3a163daf00c2a9e7bc10d4a481bf358db0
parent3be633c0aad43874705355c1fe6c8a4df92f5a8f (diff)
downloadmullvadvpn-d7061bb40f7b039a1508a3d6a6b514aa3defe33b.tar.xz
mullvadvpn-d7061bb40f7b039a1508a3d6a6b514aa3defe33b.zip
Fix 'service marked for removal' issue by killing the existing daemon process, if necessary
-rw-r--r--dist-assets/windows/installer.nsh54
1 files changed, 54 insertions, 0 deletions
diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh
index 09e31000eb..1bf8b65ac9 100644
--- a/dist-assets/windows/installer.nsh
+++ b/dist-assets/windows/installer.nsh
@@ -45,6 +45,7 @@
!define LOG_VOID 1
# Windows error codes
+!define ERROR_SERVICE_MARKED_FOR_DELETE 1072
!define ERROR_SERVICE_DEPENDENCY_DELETED 1075
# Override electron-builder generated application settings key.
@@ -476,6 +477,13 @@
Push $0
Push $1
+ Push $2
+
+ Var /GLOBAL InstallService_Counter
+ Push 0
+ Pop $InstallService_Counter
+
+ InstallService_RegisterService:
log::Log "Running $\"mullvad-daemon$\" for it to self-register as a service"
nsExec::ExecToStack '"$INSTDIR\resources\mullvad-daemon.exe" --register-service'
@@ -486,6 +494,51 @@
${If} $0 != 0
StrCpy $R0 "Failed to install Mullvad service: error $0"
log::LogWithDetails $R0 $1
+
+ #
+ # Parse service error
+ #
+ string::Find $1 "(os error " 0
+ Pop $0
+
+ ${If} $0 == -1
+ log::Log "Failed to parse service error"
+ Goto InstallService_return
+ ${EndIf}
+
+ IntOp $0 $0 + 10
+
+ string::Find $1 ")" $0
+ Pop $2
+
+ IntOp $2 $2 - $0
+
+ ${If} $2 < 1
+ log::Log "Failed to parse service error"
+ Goto InstallService_return
+ ${EndIf}
+
+ StrCpy $0 $1 $2 $0
+
+ StrCpy $R0 "Service error code: $0"
+ log::Log $R0
+
+ #
+ # Forcibly kill old process if stuck
+ #
+ ${If} $0 == ${ERROR_SERVICE_MARKED_FOR_DELETE}
+ log::Log "Attempt to forcibly kill stuck process"
+ nsExec::ExecToStack '"$SYSDIR\taskkill.exe" /f /fi "SERVICES eq mullvadvpn"'
+ Pop $0
+ Pop $1
+
+ # Retry service installation
+ IntOp $InstallService_Counter $InstallService_Counter + 1
+ ${If} $InstallService_Counter < 2
+ Goto InstallService_RegisterService
+ ${EndIf}
+ ${EndIf}
+
Goto InstallService_return
${EndIf}
@@ -513,6 +566,7 @@
InstallService_return:
+ Pop $2
Pop $1
Pop $0