diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-08-22 08:19:24 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-08-22 08:19:24 -0300 |
| commit | ac90b76bef46ad121607a482d1421db18bfa6b37 (patch) | |
| tree | 47db94e343ee765d4e273bc202f262f16d2d8ca6 | |
| parent | 0fa07495d6a36af821e799e8dbccd7e4f34053e1 (diff) | |
| parent | cdfb69b8fb0da5c9910bc3efb0dc1b15d7b7652b (diff) | |
| download | mullvadvpn-ac90b76bef46ad121607a482d1421db18bfa6b37.tar.xz mullvadvpn-ac90b76bef46ad121607a482d1421db18bfa6b37.zip | |
Merge branch 'revert-to-tokio-timer-0.1'
| -rw-r--r-- | Cargo.lock | 12 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/relays.rs | 20 |
3 files changed, 21 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock index 7a41a750d2..bb3e67aa73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -863,7 +863,7 @@ dependencies = [ "talpid-ipc 0.1.0", "talpid-types 0.1.0", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "windows-service 0.1.0 (git+https://github.com/mullvad/windows-service-rs.git?rev=55c5dfb372e6b3f5607a3159c5388d27b6b84ff6)", @@ -1770,6 +1770,15 @@ dependencies = [ [[package]] name = "tokio-timer" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-timer" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -2201,6 +2210,7 @@ source = "git+https://github.com/mullvad/rust-openssl#4dbd237fe1f6454d8a0042ccf4 "checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" "checksum tokio-tcp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b4c329b47f071eb8a746040465fa751bd95e4716e98daef6a9b4e434c17d565" "checksum tokio-threadpool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24ab84f574027b0e875378f31575cf175360891919e93a3490f07e76e00e4efb" +"checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" "checksum tokio-timer 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1c76b4e97a4f61030edff8bd272364e4f731b9f54c7307eb4eb733c3926eb96a" "checksum tokio-udp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43eb534af6e8f37d43ab1b612660df14755c42bd003c5f8d2475ee78cc4600c0" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 42d4911d01..bd6add0daf 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -23,7 +23,7 @@ uuid = { version = "0.6", features = ["v4"] } lazy_static = "1.0" rand = "0.5" tokio-core = "0.1" -tokio-timer = "0.2" +tokio-timer = "0.1" regex = "1.0" mullvad-ipc-client = { path = "../mullvad-ipc-client" } diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs index 6d33c8900f..4b0b07217e 100644 --- a/mullvad-daemon/src/relays.rs +++ b/mullvad-daemon/src/relays.rs @@ -17,11 +17,11 @@ use std::fs::File; use std::net::IpAddr; use std::path::{Path, PathBuf}; use std::sync::{mpsc, Arc, Mutex, MutexGuard}; -use std::time::{self, Duration, Instant, SystemTime}; +use std::time::{self, Duration, SystemTime}; use std::{io, thread}; use rand::{self, Rng, ThreadRng}; -use tokio_timer::{Deadline, DeadlineError}; +use tokio_timer::{TimeoutError, Timer}; const RELAYS_FILENAME: &str = "relays.json"; const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(15); @@ -38,12 +38,9 @@ error_chain! { } } -impl From<DeadlineError<Error>> for Error { - fn from(e: DeadlineError<Error>) -> Error { - match e.into_inner() { - Some(inner_e) => inner_e, - None => Error::from_kind(ErrorKind::DownloadTimeoutError), - } +impl<F> From<TimeoutError<F>> for Error { + fn from(_: TimeoutError<F>) -> Error { + Error::from_kind(ErrorKind::DownloadTimeoutError) } } @@ -389,7 +386,7 @@ impl RelayListUpdater { .chain_err(|| "Failed to update list of relays") { Ok(()) => info!("Updated list of relays"), - Err(error) => error!("{}", error), + Err(error) => error!("{}", error.display_chain()), } } } @@ -437,12 +434,13 @@ impl RelayListUpdater { fn download_relay_list(&mut self) -> Result<RelayList> { info!("Downloading list of relays..."); - let timeout_instant = Instant::now() + DOWNLOAD_TIMEOUT; let download_future = self .rpc_client .relay_list() .map_err(|e| Error::with_chain(e, ErrorKind::DownloadError)); - let relay_list = Deadline::new(download_future, timeout_instant).wait()?; + let relay_list = Timer::default() + .timeout(download_future, DOWNLOAD_TIMEOUT) + .wait()?; Ok(relay_list) } |
