aboutsummaryrefslogtreecommitdiff
path: root/device/device.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-02-02 10:46:34 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-03 00:57:57 +0100
commit8a374a35a0fe62dfd86df2c16166d2bb84115b93 (patch)
treed712eee9dbb5772f9dd922a15b168a50ba74169d /device/device.go
parent48460703229d73fbacdd0d6b0d0f01a54f7ce751 (diff)
downloadwireguard-go-8a374a35a0fe62dfd86df2c16166d2bb84115b93.tar.gz
wireguard-go-8a374a35a0fe62dfd86df2c16166d2bb84115b93.zip
device: tie encryption queue lifetime to the peers that write to it
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/device.go')
-rw-r--r--device/device.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/device/device.go b/device/device.go
index 5f36036..d860ed3 100644
--- a/device/device.go
+++ b/device/device.go
@@ -397,6 +397,10 @@ func (device *Device) Close() {
device.isUp.Set(false)
+ // Remove peers before closing queues,
+ // because peers assume that queues are active.
+ device.RemoveAllPeers()
+
// We kept a reference to the encryption and decryption queues,
// in case we started any new peers that might write to them.
// No new peers are coming; we are done with these queues.
@@ -405,8 +409,6 @@ func (device *Device) Close() {
device.queue.handshake.wg.Done()
device.state.stopping.Wait()
- device.RemoveAllPeers()
-
device.rate.limiter.Close()
device.state.changing.Set(false)