Skip to content

Commit

Permalink
fixup: keep split tunnel error state
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Dec 22, 2022
1 parent ef9b3e4 commit 81c18a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
24 changes: 22 additions & 2 deletions talpid-core/src/split_tunnel/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,18 @@ impl SplitTunnel {
pub fn new(
runtime: tokio::runtime::Handle,
resource_dir: PathBuf,
daemon_tx: Weak<mpsc::UnboundedSender<TunnelCommand>>,
volume_update_rx: mpsc::UnboundedReceiver<()>,
route_manager: RouteManagerHandle,
) -> Result<Self, Error> {
let excluded_processes = Arc::new(RwLock::new(HashMap::new()));

let (request_tx, handle) =
Self::spawn_request_thread(resource_dir, volume_update_rx, excluded_processes.clone())?;
let (request_tx, handle) = Self::spawn_request_thread(
resource_dir,
daemon_tx,
volume_update_rx,
excluded_processes.clone(),
)?;

let (event_thread, quit_event) =
Self::spawn_event_listener(handle, excluded_processes.clone())?;
Expand Down Expand Up @@ -406,6 +411,7 @@ impl SplitTunnel {

fn spawn_request_thread(
resource_dir: PathBuf,
daemon_tx: Weak<mpsc::UnboundedSender<TunnelCommand>>,
volume_update_rx: mpsc::UnboundedReceiver<()>,
excluded_processes: Arc<RwLock<HashMap<usize, ExcludedProcess>>>,
) -> Result<(RequestTx, Arc<driver::DeviceHandle>), Error> {
Expand Down Expand Up @@ -533,6 +539,20 @@ impl SplitTunnel {
}
} else {
log_response = Some(response);

if let Some(daemon_tx) = daemon_tx.upgrade() {
log::debug!(
"Entering error state due to failed request/ioctl: {}",
request_name
);
daemon_tx.unbounded_send(TunnelCommand::Block(
ErrorStateCause::SplitTunnelError,
));
} else {
log::error!(
"Cannot handle failed request since tunnel state machine is down"
);
}
}
if let Some(Err(error)) = log_response {
log::error!(
Expand Down
1 change: 1 addition & 0 deletions talpid-core/src/tunnel_state_machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ impl TunnelStateMachine {
let split_tunnel = split_tunnel::SplitTunnel::new(
runtime.clone(),
args.resource_dir.clone(),
args.command_tx.clone(),
volume_update_rx,
route_manager
.handle()
Expand Down

0 comments on commit 81c18a5

Please sign in to comment.