From 684ee3c5393ffad499b5646fc1a4df41f629ca55 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Wed, 7 Aug 2024 10:08:16 +0200 Subject: [PATCH 1/2] Fix shutdown issue on Android The daemon never received the shutdown event, causing it to never actually triggering a shutdown. This was fixed by actually using the correct `DaemonCommandChannel` to send the shutdown event. --- mullvad-daemon/src/lib.rs | 7 +++---- mullvad-daemon/src/main.rs | 7 ++++++- mullvad-jni/src/lib.rs | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 49bf0730648b..3b216edf3b89 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -589,19 +589,18 @@ impl Daemon { settings_dir: PathBuf, cache_dir: PathBuf, rpc_socket_path: PathBuf, + daemon_command_channel: DaemonCommandChannel, #[cfg(target_os = "android")] android_context: AndroidContext, ) -> Result { #[cfg(target_os = "macos")] macos::bump_filehandle_limit(); - let command_channel = DaemonCommandChannel::new(); - let command_sender = command_channel.sender(); - + let command_sender = daemon_command_channel.sender(); let management_interface = ManagementInterfaceServer::start(command_sender, rpc_socket_path) .map_err(Error::ManagementInterfaceError)?; - let (internal_event_tx, internal_event_rx) = command_channel.destructure(); + let (internal_event_tx, internal_event_rx) = daemon_command_channel.destructure(); mullvad_api::proxy::ApiConnectionMode::try_delete_cache(&cache_dir).await; let api_runtime = mullvad_api::Runtime::with_cache( diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 86b718e323c3..aee5191366de 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -2,7 +2,9 @@ use std::{path::PathBuf, thread, time::Duration}; #[cfg(not(windows))] use mullvad_daemon::cleanup_old_rpc_socket; -use mullvad_daemon::{logging, rpc_uniqueness_check, runtime, version, Daemon}; +use mullvad_daemon::{ + logging, rpc_uniqueness_check, runtime, version, Daemon, DaemonCommandChannel, +}; use talpid_types::ErrorExt; mod cli; @@ -197,12 +199,15 @@ async fn create_daemon(log_dir: Option) -> Result { let cache_dir = mullvad_paths::cache_dir() .map_err(|e| e.display_chain_with_msg("Unable to get cache dir"))?; + let daemon_command_channel = DaemonCommandChannel::new(); + Daemon::start( log_dir, resource_dir, settings_dir, cache_dir, rpc_socket_path, + daemon_command_channel, ) .await .map_err(|e| e.display_chain_with_msg("Unable to initialize daemon")) diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index 6c045b061f51..755cfce62341 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -165,6 +165,7 @@ fn spawn_daemon( rpc_socket, files_dir, cache_dir, + daemon_command_channel, android_context, ))?; @@ -179,6 +180,7 @@ async fn spawn_daemon_inner( rpc_socket: PathBuf, files_dir: PathBuf, cache_dir: PathBuf, + daemon_command_channel: DaemonCommandChannel, android_context: AndroidContext, ) -> Result, Error> { cleanup_old_rpc_socket(&rpc_socket).await; @@ -189,6 +191,7 @@ async fn spawn_daemon_inner( files_dir, cache_dir, rpc_socket, + daemon_command_channel, android_context, ) .await From bcfe7f84e852292adacab1f167fa7313496fc97a Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Wed, 7 Aug 2024 10:10:39 +0200 Subject: [PATCH 2/2] Remove unneeded clippy allow --- mullvad-daemon/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 3b216edf3b89..8594d1d7a05f 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -582,7 +582,6 @@ pub struct Daemon { } impl Daemon { - #[allow(clippy::too_many_arguments)] pub async fn start( log_dir: Option, resource_dir: PathBuf,