diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-05-22 14:28:49 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-05-22 14:28:49 +0200 |
| commit | ce6f18887987675762df78a6499bb4d8f3c56618 (patch) | |
| tree | 8054965cb772d1d2d817774641192e75e0566095 | |
| parent | 8f5f33a79bcf8e6acf718aeb6b4fac22e97a6e4f (diff) | |
| parent | 1d9812d828c145625bcdfc1806b6052d54f71b5e (diff) | |
| download | mullvadvpn-ce6f18887987675762df78a6499bb4d8f3c56618.tar.xz mullvadvpn-ce6f18887987675762df78a6499bb4d8f3c56618.zip | |
Merge branch 'cleanup-and-fixes'
| -rw-r--r-- | talpid_core/src/process/monitor.rs | 15 | ||||
| -rw-r--r-- | talpid_core/src/tunnel/openvpn.rs | 19 |
2 files changed, 17 insertions, 17 deletions
diff --git a/talpid_core/src/process/monitor.rs b/talpid_core/src/process/monitor.rs index bab2876e05..1568d80615 100644 --- a/talpid_core/src/process/monitor.rs +++ b/talpid_core/src/process/monitor.rs @@ -29,7 +29,9 @@ impl ChildMonitor { /// guaranteed to fire before this method returns. pub fn wait(&mut self) -> io::Result<&process::Output> { if let Some(thread) = self.thread.take() { - let _ = thread.join(); + if let Err(e) = thread.join() { + error!("Panic in the on_exit callback in ChildMonitor: {:?}", e); + } } self.child.wait() } @@ -44,7 +46,7 @@ impl ChildMonitor { impl Drop for ChildMonitor { fn drop(&mut self) { let _ = self.kill(); - let _ = self.wait(); + let _ = self.child.wait(); } } @@ -57,15 +59,6 @@ mod child_monitor_tests { use std::sync::mpsc; use std::time::Duration; - /// Tries to recv a message from the given `$rx` for one second and tries to match it with the - /// given expected value, `$expected` - macro_rules! assert_event { - ($rx:ident, $expected:pat) => {{ - let result = $rx.recv_timeout(Duration::new(1, 0)); - assert_matches!(result, $expected); - }} - } - fn echo_cmd(s: &str) -> Expression { cmd("echo", &[s]).stdout_capture().unchecked() } diff --git a/talpid_core/src/tunnel/openvpn.rs b/talpid_core/src/tunnel/openvpn.rs index 35361bb1fd..c0d65ce462 100644 --- a/talpid_core/src/tunnel/openvpn.rs +++ b/talpid_core/src/tunnel/openvpn.rs @@ -1,5 +1,5 @@ use jsonrpc_core::{Error, IoHandler}; -use openvpn_ffi::{OpenVpnEnv, OpenVpnPluginEvent}; +use openvpn_ffi; use talpid_ipc; @@ -11,7 +11,8 @@ pub struct OpenVpnEventDispatcher { impl OpenVpnEventDispatcher { /// Construct and start the IPC server with the given event listener callback. pub fn start<L>(on_event: L) -> talpid_ipc::Result<Self> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static + where L: Fn(openvpn_ffi::OpenVpnPluginEvent, openvpn_ffi::OpenVpnEnv), + L: Send + Sync + 'static { let rpc = OpenVpnEventApiImpl { on_event }; let mut io = IoHandler::new(); @@ -37,22 +38,28 @@ mod api { build_rpc_trait! { pub trait OpenVpnEventApi { #[rpc(name = "openvpn_event")] - fn openvpn_event(&self, OpenVpnPluginEvent, OpenVpnEnv) -> Result<(), Error>; + fn openvpn_event(&self, + openvpn_ffi::OpenVpnPluginEvent, + openvpn_ffi::OpenVpnEnv) + -> Result<(), Error>; } } } use self::api::*; struct OpenVpnEventApiImpl<L> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static + where L: Fn(openvpn_ffi::OpenVpnPluginEvent, openvpn_ffi::OpenVpnEnv) + Send + Sync + 'static { on_event: L, } impl<L> OpenVpnEventApi for OpenVpnEventApiImpl<L> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static + where L: Fn(openvpn_ffi::OpenVpnPluginEvent, openvpn_ffi::OpenVpnEnv) + Send + Sync + 'static { - fn openvpn_event(&self, event: OpenVpnPluginEvent, env: OpenVpnEnv) -> Result<(), Error> { + fn openvpn_event(&self, + event: openvpn_ffi::OpenVpnPluginEvent, + env: openvpn_ffi::OpenVpnEnv) + -> Result<(), Error> { debug!("OpenVPN event {:?}", event); (self.on_event)(event, env); Ok(()) |
