diff options
Diffstat (limited to 'talpid-openvpn-plugin/src/processing.rs')
| -rw-r--r-- | talpid-openvpn-plugin/src/processing.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs index b76e92e409..5fc2a1312e 100644 --- a/talpid-openvpn-plugin/src/processing.rs +++ b/talpid-openvpn-plugin/src/processing.rs @@ -1,5 +1,6 @@ use openvpn_plugin; use std::collections::HashMap; +use std::sync::Mutex; use talpid_ipc::{IpcServerId, WsIpcClient}; error_chain! { @@ -13,14 +14,17 @@ error_chain! { /// Struct processing OpenVPN events and notifies listeners over IPC pub struct EventProcessor { - ipc_client: WsIpcClient, + ipc_client: Mutex<WsIpcClient>, } impl EventProcessor { pub fn new(server_id: IpcServerId) -> Result<EventProcessor> { trace!("Creating EventProcessor"); - let ipc_client = WsIpcClient::new(server_id).chain_err(|| "Unable to create IPC client")?; - Ok(EventProcessor { ipc_client }) + let ipc_client = + WsIpcClient::connect(server_id).chain_err(|| "Unable to create IPC client")?; + Ok(EventProcessor { + ipc_client: Mutex::new(ipc_client), + }) } pub fn process_event( @@ -30,6 +34,8 @@ impl EventProcessor { ) -> Result<()> { trace!("Processing \"{:?}\" event", event); self.ipc_client + .lock() + .expect("a thread panicked while using the RPC client in the OpenVPN plugin") .call("openvpn_event", &(event, env)) .map(|_: Option<()>| ()) .chain_err(|| ErrorKind::IpcSendingError) |
