device: tie encryption queue lifetime to the peers that write to it

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder authored and Jason A. Donenfeld committed 2021-02-03 00:57:57 +01:00
1 parent 4846070322
commit 8a374a35a0
3 files changed
+6 -4

No files matched your search

+2
View File
@@ -177,6 +177,7 @@ func (peer *Peer) Start() {
if peer.queue.staged == nil {
peer.queue.staged = make(chan *QueueOutboundElement, QueueStagedSize)
}
peer.device.queue.encryption.wg.Add(1) // keep encryption queue open for our writes
peer.timersInit()
peer.handshake.lastSentHandshake = time.Now().Add(-(RekeyTimeout + time.Second))
@@ -248,6 +249,7 @@ func (peer *Peer) Stop() {
close(peer.queue.inbound)
close(peer.queue.outbound)
peer.stopping.Wait()
peer.device.queue.encryption.wg.Done() // no more writes to encryption queue from us
peer.ZeroAndFlushAll()
}