Skip to content

Commit 8066494

Browse files
Serock3MarkusPettersson98
authored andcommitted
Pass down shutdown flag
1 parent da371fe commit 8066494

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

mullvad-daemon/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ use std::{
7676
sync::{Arc, Weak},
7777
time::Duration,
7878
};
79-
use talpid_core::split_tunnel;
8079
use talpid_core::{
8180
mpsc::Sender,
81+
split_tunnel,
8282
tunnel_state_machine::{self, TunnelCommand, TunnelStateMachineHandle},
8383
};
8484
#[cfg(target_os = "android")]
@@ -352,7 +352,7 @@ pub enum DaemonCommand {
352352
SetObfuscationSettings(ResponseTx<(), settings::Error>, ObfuscationSettings),
353353
/// Saves the target tunnel state and enters a blocking state. The state is restored
354354
/// upon restart.
355-
PrepareRestart,
355+
PrepareRestart(bool),
356356
/// Causes a socket to bypass the tunnel. This has no effect when connected. It is only used
357357
/// to bypass the tunnel in blocking states.
358358
#[cfg(target_os = "android")]
@@ -1290,9 +1290,7 @@ where
12901290
SetObfuscationSettings(tx, settings) => {
12911291
self.on_set_obfuscation_settings(tx, settings).await
12921292
}
1293-
PrepareRestart => {
1294-
self.on_prepare_restart(true /*TODO: This should be passed down!*/)
1295-
}
1293+
PrepareRestart(shutdown) => self.on_prepare_restart(shutdown),
12961294
#[cfg(target_os = "android")]
12971295
BypassSocket(fd, tx) => self.on_bypass_socket(fd, tx),
12981296
#[cfg(target_os = "android")]
@@ -2702,7 +2700,8 @@ where
27022700

27032701
/// Prepare the daemon for a restart by setting the target state to [`TargetState::Secured`].
27042702
///
2705-
/// - `shutdown`: If the daemon should shut down itself when .. TODO
2703+
/// - `shutdown`: If the daemon should shut down itself when after setting the secured target
2704+
/// state. set to `false` if the intention is to close the daemon process manually.
27062705
fn on_prepare_restart(&mut self, shutdown: bool) {
27072706
// TODO: See if this can be made to also shut down the daemon
27082707
// without causing the service to be restarted.

mullvad-daemon/src/management_interface.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ use mullvad_management_interface::{
88
types::{self, daemon_event, management_service_server::ManagementService},
99
Code, Request, Response, Status,
1010
};
11-
use mullvad_types::settings::DnsOptions;
1211
use mullvad_types::{
1312
account::AccountToken,
1413
relay_constraints::{
1514
BridgeSettings, BridgeState, ObfuscationSettings, RelayOverride, RelaySettings,
1615
},
1716
relay_list::RelayList,
18-
settings::Settings,
17+
settings::{DnsOptions, Settings},
1918
states::{TargetState, TunnelState},
2019
version,
2120
wireguard::{RotationInterval, RotationIntervalError},
@@ -102,9 +101,9 @@ impl ManagementService for ManagementServiceImpl {
102101
Ok(Response::new(UnboundedReceiverStream::new(rx)))
103102
}
104103

105-
async fn prepare_restart(&self, _: Request<bool>) -> ServiceResult<()> {
104+
async fn prepare_restart(&self, shutdown: Request<bool>) -> ServiceResult<()> {
106105
log::debug!("prepare_restart");
107-
self.send_command_to_daemon(DaemonCommand::PrepareRestart)?;
106+
self.send_command_to_daemon(DaemonCommand::PrepareRestart(shutdown.into_inner()))?;
108107
Ok(Response::new(()))
109108
}
110109

0 commit comments

Comments
 (0)