diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-07-08 15:38:42 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-07-13 15:57:37 +0200 |
| commit | e52236b751a0d4a3ae9de9b6ba5569ef3faff495 (patch) | |
| tree | 0db878501636ebdd4cecb9732d440852d2cbd5e7 | |
| parent | 66a994935c165ef7899ca31c1c1714471bb26ca8 (diff) | |
| download | mullvadvpn-e52236b751a0d4a3ae9de9b6ba5569ef3faff495.tar.xz mullvadvpn-e52236b751a0d4a3ae9de9b6ba5569ef3faff495.zip | |
Fix tokio runtime builders
| -rw-r--r-- | mullvad-daemon/src/main.rs | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/runtime.rs | 8 | ||||
| -rw-r--r-- | mullvad-daemon/src/system_service.rs | 2 | ||||
| -rw-r--r-- | mullvad-jni/src/lib.rs | 2 | ||||
| -rw-r--r-- | mullvad-problem-report/src/lib.rs | 5 | ||||
| -rw-r--r-- | talpid-core/src/routing/linux.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/openvpn/mod.rs | 5 | ||||
| -rw-r--r-- | talpid-openvpn-plugin/src/processing.rs | 5 |
8 files changed, 12 insertions, 21 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index a355f94e44..53d38f8902 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -26,7 +26,7 @@ fn main() { std::process::exit(1) }); - let mut runtime = new_runtime_builder().build().unwrap_or_else(|error| { + let runtime = new_runtime_builder().build().unwrap_or_else(|error| { eprintln!("{}", error.display_chain()); std::process::exit(1); }); diff --git a/mullvad-daemon/src/runtime.rs b/mullvad-daemon/src/runtime.rs index 3c60b133e8..34bdf60390 100644 --- a/mullvad-daemon/src/runtime.rs +++ b/mullvad-daemon/src/runtime.rs @@ -1,11 +1,7 @@ use tokio::runtime; pub fn new_runtime_builder() -> runtime::Builder { - let mut builder = runtime::Builder::new(); - builder - .threaded_scheduler() - .core_threads(4) - .max_threads(8) - .enable_all(); + let mut builder = runtime::Builder::new_multi_thread(); + builder.worker_threads(4).enable_all(); builder } diff --git a/mullvad-daemon/src/system_service.rs b/mullvad-daemon/src/system_service.rs index bd51f64999..34580e93e0 100644 --- a/mullvad-daemon/src/system_service.rs +++ b/mullvad-daemon/src/system_service.rs @@ -105,7 +105,7 @@ pub fn handle_service_main(_arguments: Vec<OsString>) { let log_dir = crate::get_log_dir(cli::get_config()).expect("Log dir should be available here"); let runtime = new_runtime_builder().build(); - let mut runtime = match runtime { + let runtime = match runtime { Err(error) => { log::error!("{}", error.display_chain()); persistent_service_status diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index 38c5e54423..0d4485b3f1 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -231,7 +231,7 @@ fn spawn_daemon( .map_err(Error::CreateGlobalReference)?; let (tx, rx) = mpsc::channel(); - let mut runtime = new_runtime_builder() + let runtime = new_runtime_builder() .build() .map_err(Error::InitializeTokioRuntime)?; diff --git a/mullvad-problem-report/src/lib.rs b/mullvad-problem-report/src/lib.rs index a3f8659ac8..26cbcb4fb1 100644 --- a/mullvad-problem-report/src/lib.rs +++ b/mullvad-problem-report/src/lib.rs @@ -273,9 +273,8 @@ pub fn send_problem_report( let metadata = ProblemReport::parse_metadata(&report_content).unwrap_or_else(|| metadata::collect()); - let mut runtime = tokio::runtime::Builder::new() - .threaded_scheduler() - .core_threads(2) + let runtime = tokio::runtime::Builder::new_multi_thread() + .worker_threads(2) .enable_all() .build() .map_err(Error::CreateRuntime)?; diff --git a/talpid-core/src/routing/linux.rs b/talpid-core/src/routing/linux.rs index a63430fed3..6dc5489de3 100644 --- a/talpid-core/src/routing/linux.rs +++ b/talpid-core/src/routing/linux.rs @@ -826,7 +826,7 @@ mod test { /// Tests if dropping inside a tokio runtime panics #[test] fn test_drop_in_executor() { - let mut runtime = tokio::runtime::Runtime::new().expect("Failed to initialize runtime"); + let runtime = tokio::runtime::Runtime::new().expect("Failed to initialize runtime"); runtime.block_on(async { let manager = RouteManagerImpl::new(HashSet::new()) .await @@ -838,7 +838,7 @@ mod test { /// Tests if dropping outside a runtime panics #[test] fn test_drop() { - let mut runtime = tokio::runtime::Runtime::new().expect("Failed to initialize runtime"); + let runtime = tokio::runtime::Runtime::new().expect("Failed to initialize runtime"); let manager = runtime.block_on(async { RouteManagerImpl::new(HashSet::new()) .await diff --git a/talpid-core/src/tunnel/openvpn/mod.rs b/talpid-core/src/tunnel/openvpn/mod.rs index f25f2624da..3bdbf3ff30 100644 --- a/talpid-core/src/tunnel/openvpn/mod.rs +++ b/talpid-core/src/tunnel/openvpn/mod.rs @@ -528,9 +528,8 @@ impl<C: OpenVpnBuilder + Send + 'static> OpenVpnMonitor<C> { format!("/tmp/talpid-openvpn-{}", uuid) }; - let mut runtime = tokio::runtime::Builder::new() - .threaded_scheduler() - .core_threads(1) + let runtime = tokio::runtime::Builder::new_multi_thread() + .worker_threads(1) .enable_all() .build() .map_err(Error::RuntimeError)?; diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs index e6d2a77349..2e715707b7 100644 --- a/talpid-openvpn-plugin/src/processing.rs +++ b/talpid-openvpn-plugin/src/processing.rs @@ -25,10 +25,7 @@ pub struct EventProcessor { impl EventProcessor { pub fn new(arguments: Arguments) -> Result<EventProcessor, Error> { log::trace!("Creating EventProcessor"); - let mut runtime = runtime::Builder::new() - .basic_scheduler() - .core_threads(1) - .max_threads(1) + let runtime = runtime::Builder::new_current_thread() .enable_all() .build() .map_err(Error::CreateRuntime)?; |
