aboutsummaryrefslogtreecommitdiffstats
path: root/src/router/device.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-28 16:27:26 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-28 16:27:26 +0200
commit6785aa4cb56833131b69f4d2b44301908b1a1b4c (patch)
treed9dc6ec7a3c45291f44ae3e8d707200a1b1da410 /src/router/device.rs
parentRenamed confirmed -> initator on keypair (diff)
downloadwireguard-rs-6785aa4cb56833131b69f4d2b44301908b1a1b4c.tar.xz
wireguard-rs-6785aa4cb56833131b69f4d2b44301908b1a1b4c.zip
Join with worker threads on device drop
Diffstat (limited to 'src/router/device.rs')
-rw-r--r--src/router/device.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/router/device.rs b/src/router/device.rs
index bee4ad4..a7f0590 100644
--- a/src/router/device.rs
+++ b/src/router/device.rs
@@ -9,7 +9,8 @@ use crossbeam_deque::{Injector, Steal, Stealer, Worker};
use spin;
use treebitmap::IpLookupTable;
-use super::super::types::KeyPair;
+use super::super::types::{Bind, KeyPair, Tun};
+
use super::anti_replay::AntiReplay;
use super::peer;
use super::peer::{Peer, PeerInner};
@@ -62,16 +63,15 @@ impl<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<T>> Drop for Devi
let device = &self.0;
device.running.store(false, Ordering::SeqCst);
- // eat all parallel jobs
- while match device.injector.steal() {
- Steal::Empty => true,
+ // join all worker threads
+ while match self.1.pop() {
+ Some(handle) => {
+ handle.thread().unpark();
+ handle.join().unwrap();
+ true
+ }
_ => false,
} {}
-
- // unpark all threads
- for handle in &self.1 {
- handle.thread().unpark();
- }
}
}