diff options
author | Josh Bleecher Snyder <josh@tailscale.com> | 2021-02-08 12:38:19 -0800 |
---|---|---|
committer | Josh Bleecher Snyder <josh@tailscale.com> | 2021-02-08 12:38:19 -0800 |
commit | 57aadfcb14776a792e629dd7c22be066b7e2ed20 (patch) | |
tree | 37c1a8b94854577d0cc6509a5a19a3f913f2a129 /device/device.go | |
parent | af408eb9400bd94a01eea5ece8fa3da62c911818 (diff) |
device: create channels.go
We have a bunch of stupid channel tricks, and I'm about to add more.
Give them their own file. This commit is 100% code movement.
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/device.go')
-rw-r--r-- | device/device.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/device/device.go b/device/device.go index 52b0143..b93ad22 100644 --- a/device/device.go +++ b/device/device.go @@ -133,67 +133,6 @@ func (device *Device) isUp() bool { return device.deviceState() == deviceStateUp } -// An outboundQueue is a channel of QueueOutboundElements awaiting encryption. -// An outboundQueue is ref-counted using its wg field. -// An outboundQueue created with newOutboundQueue has one reference. -// Every additional writer must call wg.Add(1). -// Every completed writer must call wg.Done(). -// When no further writers will be added, -// call wg.Done to remove the initial reference. -// When the refcount hits 0, the queue's channel is closed. -type outboundQueue struct { - c chan *QueueOutboundElement - wg sync.WaitGroup -} - -func newOutboundQueue() *outboundQueue { - q := &outboundQueue{ - c: make(chan *QueueOutboundElement, QueueOutboundSize), - } - q.wg.Add(1) - go func() { - q.wg.Wait() - close(q.c) - }() - return q -} - -// A inboundQueue is similar to an outboundQueue; see those docs. -type inboundQueue struct { - c chan *QueueInboundElement - wg sync.WaitGroup -} - -func newInboundQueue() *inboundQueue { - q := &inboundQueue{ - c: make(chan *QueueInboundElement, QueueInboundSize), - } - q.wg.Add(1) - go func() { - q.wg.Wait() - close(q.c) - }() - return q -} - -// A handshakeQueue is similar to an outboundQueue; see those docs. -type handshakeQueue struct { - c chan QueueHandshakeElement - wg sync.WaitGroup -} - -func newHandshakeQueue() *handshakeQueue { - q := &handshakeQueue{ - c: make(chan QueueHandshakeElement, QueueHandshakeSize), - } - q.wg.Add(1) - go func() { - q.wg.Wait() - close(q.c) - }() - return q -} - /* Converts the peer into a "zombie", which remains in the peer map, * but processes no packets and does not exists in the routing table. * |