diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-11-19 13:14:09 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-11-19 14:47:22 +0100 |
| commit | 75603b42d7732440d225d1676f6ea7698ebd26b4 (patch) | |
| tree | bdd07a2bb317f90929f33be927cd9e5463fcf8e4 | |
| parent | 1ce6a645a1726b5ec543333a4a205d0b57c115f5 (diff) | |
| download | mullvadvpn-75603b42d7732440d225d1676f6ea7698ebd26b4.tar.xz mullvadvpn-75603b42d7732440d225d1676f6ea7698ebd26b4.zip | |
Make problem-report tool create its own tokio Core
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | mullvad-problem-report/Cargo.toml | 1 | ||||
| -rw-r--r-- | mullvad-problem-report/src/main.rs | 12 | ||||
| -rw-r--r-- | mullvad-rpc/src/lib.rs | 5 |
4 files changed, 9 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock index 9cb7e5c622..869ae86dab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1004,6 +1004,7 @@ dependencies = [ "mullvad-rpc 0.1.0", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "rs-release 0.1.7 (git+https://github.com/mullvad/rs-release?branch=snailquote-unescape)", + "tokio-core 0.1.17 (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.6 (registry+https://github.com/rust-lang/crates.io-index)", "winres 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/mullvad-problem-report/Cargo.toml b/mullvad-problem-report/Cargo.toml index 8c2160e018..4f6d7f3547 100644 --- a/mullvad-problem-report/Cargo.toml +++ b/mullvad-problem-report/Cargo.toml @@ -23,6 +23,7 @@ env_logger = "0.5" error-chain = "0.12" lazy_static = "1.0" regex = "1.0" +tokio-core = "0.1" uuid = { version = "0.6", features = ["v4"] } mullvad-paths = { path = "../mullvad-paths" } diff --git a/mullvad-problem-report/src/main.rs b/mullvad-problem-report/src/main.rs index 8e8fb00f67..183e5591d6 100644 --- a/mullvad-problem-report/src/main.rs +++ b/mullvad-problem-report/src/main.rs @@ -13,6 +13,7 @@ extern crate error_chain; extern crate env_logger; extern crate lazy_static; extern crate regex; +extern crate tokio_core; extern crate uuid; extern crate mullvad_paths; @@ -22,6 +23,7 @@ use clap::crate_authors; use error_chain::ChainedError; use lazy_static::lazy_static; use regex::Regex; +use tokio_core::reactor::Core; use std::{ alloc::System, @@ -257,16 +259,16 @@ fn send_problem_report(user_email: &str, user_message: &str, report_path: &Path) let ca_path = mullvad_paths::resources::get_api_ca_path(); + let mut core = Core::new().unwrap(); let mut rpc_manager = mullvad_rpc::MullvadRpcFactory::new(ca_path); let rpc_http_handle = rpc_manager - .new_connection() + .new_connection_on_event_loop(&core.handle()) .chain_err(|| ErrorKind::RpcError)?; let mut rpc_client = mullvad_rpc::ProblemReportProxy::new(rpc_http_handle); - rpc_client - .problem_report(user_email, user_message, &report_content, &metadata) - .call() - .chain_err(|| ErrorKind::RpcError) + let result = + core.run(rpc_client.problem_report(user_email, user_message, &report_content, &metadata)); + result.chain_err(|| ErrorKind::RpcError) } fn write_problem_report(path: &Path, problem_report: &ProblemReport) -> io::Result<()> { diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs index 30215976e7..a5267e26db 100644 --- a/mullvad-rpc/src/lib.rs +++ b/mullvad-rpc/src/lib.rs @@ -88,11 +88,6 @@ impl MullvadRpcFactory { } } - /// Spawns a tokio core on a new thread and returns a `HttpHandle` running on that core. - pub fn new_connection(&mut self) -> Result<HttpHandle, HttpError> { - self.setup_connection(HttpTransportBuilder::standalone) - } - /// Create and returns a `HttpHandle` running on the given core handle. pub fn new_connection_on_event_loop( &mut self, |
