device: use channel close to shut down and drain outbound channel

This is a similar treatment to the handling of the encryption
channel found a few commits ago: Use the closing of the channel
to manage goroutine lifetime and shutdown.
It is considerably simpler because there is only a single writer.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2020-12-15 15:54:48 -08:00
parent e739ff71a5
commit 15af3e58ce
2 changed files with 35 additions and 56 deletions

View File

@@ -17,7 +17,7 @@ import (
)
const (
PeerRoutineNumber = 3
PeerRoutineNumber = 2
)
type Peer struct {
@@ -287,7 +287,6 @@ func (peer *Peer) Stop() {
peer.queue.Lock()
close(peer.queue.nonce)
close(peer.queue.outbound)
close(peer.queue.inbound)
peer.queue.Unlock()