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:
committed by
Jason A. Donenfeld
parent
63066ce406
commit
2832e96339
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user