diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-05-18 18:16:47 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-05-18 18:16:47 +0200 |
| commit | 3fb05e07a98fdb06eeecaffcd6acbfa7682aab67 (patch) | |
| tree | 0740fb3c10dc66f5da8ed6ef392ba387e652707a | |
| parent | e2a0d9748552278d9d37203903865bb6d00e3c0e (diff) | |
| parent | 2f55ab60019642190b1e909ce2a917303f1d4f47 (diff) | |
| download | mullvadvpn-3fb05e07a98fdb06eeecaffcd6acbfa7682aab67.tar.xz mullvadvpn-3fb05e07a98fdb06eeecaffcd6acbfa7682aab67.zip | |
Merge branch 'reduce-lazy-static-upgrade-regex'
| -rw-r--r-- | Cargo.lock | 24 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/main.rs | 16 |
3 files changed, 30 insertions, 12 deletions
diff --git a/Cargo.lock b/Cargo.lock index 38339b7f23..4f0c148946 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -772,7 +772,7 @@ dependencies = [ "mullvad-types 0.1.0", "os_pipe 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "simple-signal 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1100,6 +1100,18 @@ dependencies = [ ] [[package]] +name = "regex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "regex-syntax" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1108,6 +1120,14 @@ dependencies = [ ] [[package]] +name = "regex-syntax" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "relay" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1943,7 +1963,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" +"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" +"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b" "checksum relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum resolv-conf 0.6.0 (git+https://github.com/tailhook/resolv-conf.git)" = "<none>" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 919494c69d..b09db7e275 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -25,7 +25,7 @@ lazy_static = "1.0" rand = "0.4" tokio-core = "0.1" tokio-timer = "0.1" -regex = "0.2" +regex = "1.0" mullvad-ipc-client = { path = "../mullvad-ipc-client" } mullvad-metadata = { path = "../mullvad-metadata" } diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 14a8fe8067..af8ad25d9c 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -28,8 +28,6 @@ extern crate jsonrpc_core; extern crate jsonrpc_macros; extern crate jsonrpc_pubsub; extern crate jsonrpc_ws_server; -#[macro_use] -extern crate lazy_static; extern crate rand; extern crate tokio_core; extern crate tokio_timer; @@ -129,11 +127,9 @@ error_chain!{ } } -lazy_static! { - static ref MIN_TUNNEL_ALIVE_TIME_MS: Duration = Duration::from_millis(1000); - static ref MAX_RELAY_CACHE_AGE: Duration = Duration::from_secs(3600); - static ref RELAY_CACHE_UPDATE_TIMEOUT: Duration = Duration::from_millis(3000); -} +static MIN_TUNNEL_ALIVE_TIME: Duration = Duration::from_millis(1000); +static MAX_RELAY_CACHE_AGE: Duration = Duration::from_secs(3600); +static RELAY_CACHE_UPDATE_TIMEOUT: Duration = Duration::from_millis(3000); /// All events that can happen in the daemon. Sent from various threads and exposed interfaces. @@ -282,8 +278,8 @@ impl Daemon { ) -> relays::RelaySelector { let mut relay_selector = relays::RelaySelector::new(rpc_handle, &resource_dir, cache_dir); if let Ok(elapsed) = relay_selector.get_last_updated().elapsed() { - if elapsed > *MAX_RELAY_CACHE_AGE { - if let Err(e) = relay_selector.update(*RELAY_CACHE_UPDATE_TIMEOUT) { + if elapsed > MAX_RELAY_CACHE_AGE { + if let Err(e) = relay_selector.update(RELAY_CACHE_UPDATE_TIMEOUT) { error!("Unable to update relay cache: {}", e.display_chain()); } } @@ -772,7 +768,7 @@ impl Daemon { thread::spawn(move || { let start = Instant::now(); let result = tunnel_monitor.wait(); - if let Some(sleep_dur) = MIN_TUNNEL_ALIVE_TIME_MS.checked_sub(start.elapsed()) { + if let Some(sleep_dur) = MIN_TUNNEL_ALIVE_TIME.checked_sub(start.elapsed()) { thread::sleep(sleep_dur); } let _ = error_tx.send(DaemonEvent::TunnelExited(result)); |
