diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2019-11-20 08:53:55 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2019-11-20 08:53:55 +0100 |
| commit | 4527e0d4a63c5074f82ffda9f2015dc9ff102f13 (patch) | |
| tree | d12bb65fd9958b37d6b536b335ed9b3f610197ab | |
| parent | 3c5f6904763ab6d707650675036135e334554757 (diff) | |
| parent | 413f4ce61b6b46b31ce9ae3ef9a26795aa965161 (diff) | |
| download | mullvadvpn-4527e0d4a63c5074f82ffda9f2015dc9ff102f13.tar.xz mullvadvpn-4527e0d4a63c5074f82ffda9f2015dc9ff102f13.zip | |
Merge branch 'idiomatic-duration-constants'
| -rw-r--r-- | Cargo.lock | 6 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/system_service.rs | 13 |
3 files changed, 9 insertions, 12 deletions
diff --git a/Cargo.lock b/Cargo.lock index d24b4e225a..5e57baa371 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1263,7 +1263,7 @@ dependencies = [ "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "windows-service 0.2.0 (git+https://github.com/mullvad/windows-service-rs.git?rev=f518cd53a842985eea08c236a6ebd072ee5d88ac)", + "windows-service 0.2.0 (git+https://github.com/mullvad/windows-service-rs.git?rev=48d755b0afbf259ba547d4defc3e9340d1436cf6)", "winres 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3071,7 +3071,7 @@ dependencies = [ [[package]] name = "windows-service" version = "0.2.0" -source = "git+https://github.com/mullvad/windows-service-rs.git?rev=f518cd53a842985eea08c236a6ebd072ee5d88ac#f518cd53a842985eea08c236a6ebd072ee5d88ac" +source = "git+https://github.com/mullvad/windows-service-rs.git?rev=48d755b0afbf259ba547d4defc3e9340d1436cf6#48d755b0afbf259ba547d4defc3e9340d1436cf6" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "err-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3428,7 +3428,7 @@ dependencies = [ "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" "checksum winconsole 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ef84b96d10db72dd980056666d7f1e7663ce93d82fa33b63e71c966f4cf5032" -"checksum windows-service 0.2.0 (git+https://github.com/mullvad/windows-service-rs.git?rev=f518cd53a842985eea08c236a6ebd072ee5d88ac)" = "<none>" +"checksum windows-service 0.2.0 (git+https://github.com/mullvad/windows-service-rs.git?rev=48d755b0afbf259ba547d4defc3e9340d1436cf6)" = "<none>" "checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" "checksum winres 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ff4fb510bbfe5b8992ff15f77a2e6fe6cf062878f0eda00c0f44963a807ca5dc" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 7bc8ce4564..5eeb095d93 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -55,7 +55,7 @@ simple-signal = "1.1" [target.'cfg(windows)'.dependencies] ctrlc = "3.0" -windows-service = { git = "https://github.com/mullvad/windows-service-rs.git", rev = "f518cd53a842985eea08c236a6ebd072ee5d88ac" } +windows-service = { git = "https://github.com/mullvad/windows-service-rs.git", rev = "48d755b0afbf259ba547d4defc3e9340d1436cf6" } winapi = "0.3" [target.'cfg(windows)'.build-dependencies] diff --git a/mullvad-daemon/src/system_service.rs b/mullvad-daemon/src/system_service.rs index 81e96d66a4..9dcb56efb3 100644 --- a/mullvad-daemon/src/system_service.rs +++ b/mullvad-daemon/src/system_service.rs @@ -27,6 +27,9 @@ static SERVICE_NAME: &'static str = "MullvadVPN"; static SERVICE_DISPLAY_NAME: &'static str = "Mullvad VPN Service"; static SERVICE_TYPE: ServiceType = ServiceType::OWN_PROCESS; +const SERVICE_RECOVERY_LAST_RESTART_DELAY: Duration = Duration::from_secs(60 * 10); +const SERVICE_FAILURE_RESET_PERIOD: Duration = Duration::from_secs(60 * 15); + pub fn run() -> Result<(), String> { // Start the service dispatcher. // This will block current thread until the service stopped and spawn `service_main` on a @@ -257,8 +260,6 @@ pub fn install_service() -> Result<(), InstallError> { .or(service_manager.open_service(SERVICE_NAME, service_access)) .map_err(InstallError::CreateService)?; - const TEN_MINUTES_AS_SECS: u64 = 60 * 10; - let recovery_actions = vec![ ServiceAction { action_type: ServiceActionType::Restart, @@ -270,16 +271,12 @@ pub fn install_service() -> Result<(), InstallError> { }, ServiceAction { action_type: ServiceActionType::Restart, - delay: Duration::from_secs(TEN_MINUTES_AS_SECS), + delay: SERVICE_RECOVERY_LAST_RESTART_DELAY, }, ]; - const FIFTEEN_MINUTES_AS_SECS: u64 = 60 * 15; - let failure_actions = ServiceFailureActions { - reset_period: ServiceFailureResetPeriod::After(Duration::from_secs( - FIFTEEN_MINUTES_AS_SECS, - )), + reset_period: ServiceFailureResetPeriod::After(SERVICE_FAILURE_RESET_PERIOD), reboot_msg: None, command: None, actions: Some(recovery_actions), |
