summaryrefslogtreecommitdiffhomepage
path: root/device/send.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-01-11 17:21:16 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-20 19:57:00 +0100
commit2fe19ce54db258d8c47ff03d8335fd28c7c7ad0f (patch)
tree6a38900d0ada9f5f8e3b8e92a38d9eaf8b5307fe /device/send.go
parent0cc15e7c7c6fc2917cb1cea8ea3f10f7d375cac4 (diff)
device: remove selects from encrypt/decrypt/inbound/outbound enqueuing
Block instead. Backpressure here is fine, probably preferable. This reduces code complexity. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/send.go')
-rw-r--r--device/send.go20
1 files changed, 2 insertions, 18 deletions
diff --git a/device/send.go b/device/send.go
index 55df4b3..c9b62e6 100644
--- a/device/send.go
+++ b/device/send.go
@@ -97,23 +97,6 @@ func addToNonceQueue(queue chan *QueueOutboundElement, elem *QueueOutboundElemen
}
}
-func addToOutboundAndEncryptionQueues(outboundQueue chan *QueueOutboundElement, encryptionQueue chan *QueueOutboundElement, elem *QueueOutboundElement) {
- select {
- case outboundQueue <- elem:
- select {
- case encryptionQueue <- elem:
- return
- default:
- elem.Drop()
- elem.peer.device.PutMessageBuffer(elem.buffer)
- elem.Unlock()
- }
- default:
- elem.peer.device.PutMessageBuffer(elem.buffer)
- elem.peer.device.PutOutboundElement(elem)
- }
-}
-
/* Queues a keepalive if no packets are queued for peer
*/
func (peer *Peer) SendKeepalive() bool {
@@ -457,7 +440,8 @@ NextPacket:
elem.Lock()
// add to parallel and sequential queue
- addToOutboundAndEncryptionQueues(peer.queue.outbound, device.queue.encryption.c, elem)
+ peer.queue.outbound <- elem
+ device.queue.encryption.c <- elem
}
}
}