Skip to content

Commit

Permalink
Merge branch 'investigate-shutdown-issue'
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Aug 7, 2024
2 parents a731328 + bcfe7f8 commit 8c7a83a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 3 additions & 5 deletions mullvad-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,26 +582,24 @@ pub struct Daemon {
}

impl Daemon {
#[allow(clippy::too_many_arguments)]
pub async fn start(
log_dir: Option<PathBuf>,
resource_dir: PathBuf,
settings_dir: PathBuf,
cache_dir: PathBuf,
rpc_socket_path: PathBuf,
daemon_command_channel: DaemonCommandChannel,
#[cfg(target_os = "android")] android_context: AndroidContext,
) -> Result<Self, Error> {
#[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(
Expand Down
7 changes: 6 additions & 1 deletion mullvad-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -197,12 +199,15 @@ async fn create_daemon(log_dir: Option<PathBuf>) -> Result<Daemon, String> {
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"))
Expand Down
3 changes: 3 additions & 0 deletions mullvad-jni/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ fn spawn_daemon(
rpc_socket,
files_dir,
cache_dir,
daemon_command_channel,
android_context,
))?;

Expand All @@ -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<tokio::task::JoinHandle<()>, Error> {
cleanup_old_rpc_socket(&rpc_socket).await;
Expand All @@ -189,6 +191,7 @@ async fn spawn_daemon_inner(
files_dir,
cache_dir,
rpc_socket,
daemon_command_channel,
android_context,
)
.await
Expand Down

0 comments on commit 8c7a83a

Please sign in to comment.