summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-10-09 09:48:58 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-10-09 10:08:38 -0300
commit7c90e03dcefe35f2521246195a906e16f2f4f391 (patch)
tree07d4a25d8e0f99ced5a395619b70b215b75512e7
parentb31a91dc1ed7552023ff342f77df22bec5a723f3 (diff)
downloadmullvadvpn-7c90e03dcefe35f2521246195a906e16f2f4f391.tar.xz
mullvadvpn-7c90e03dcefe35f2521246195a906e16f2f4f391.zip
Use `unbounded_send` method directly
Instead of the `futures::sink::Wait`, which removes the need for the `Mutex`.
-rw-r--r--talpid-core/src/tunnel_state_machine/connecting_state.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs
index d8bc5fea92..ae0c1619cc 100644
--- a/talpid-core/src/tunnel_state_machine/connecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs
@@ -1,13 +1,11 @@
use std::ffi::OsString;
use std::path::{Path, PathBuf};
-use std::sync::Mutex;
use std::thread;
use std::time::{Duration, Instant};
use error_chain::ChainedError;
-use futures::sink::Wait;
use futures::sync::{mpsc, oneshot};
-use futures::{Async, Future, Sink, Stream};
+use futures::{Async, Future, Stream};
use talpid_types::net::{TunnelEndpoint, TunnelEndpointData};
use talpid_types::tunnel::BlockReason;
@@ -72,8 +70,7 @@ impl ConnectingState {
resource_dir: &Path,
) -> Result<Self> {
let (event_tx, event_rx) = mpsc::unbounded();
- let monitor =
- Self::spawn_tunnel_monitor(&parameters, log_dir, resource_dir, event_tx.wait())?;
+ let monitor = Self::spawn_tunnel_monitor(&parameters, log_dir, resource_dir, event_tx)?;
let close_handle = monitor.close_handle();
let tunnel_close_event = Self::spawn_tunnel_monitor_wait_thread(monitor);
@@ -89,14 +86,10 @@ impl ConnectingState {
parameters: &TunnelParameters,
log_dir: &Option<PathBuf>,
resource_dir: &Path,
- events: Wait<mpsc::UnboundedSender<TunnelEvent>>,
+ events: mpsc::UnboundedSender<TunnelEvent>,
) -> Result<TunnelMonitor> {
- let event_tx = Mutex::new(events);
let on_tunnel_event = move |event| {
- let send_result = event_tx
- .lock()
- .expect("A thread panicked while sending a tunnel event")
- .send(event);
+ let send_result = events.unbounded_send(event);
if send_result.is_err() {
warn!("Tunnel state machine stopped before tunnel event was received");