aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-01-17 09:40:18 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-20 19:57:05 +0100
commit7ee95e053c280796ecfb5533000915e7daa13f69 (patch)
tree51cd8efc8e642628f8eb8064f852812cdeaec86f
parenttun/wintun/memmod: gofmt (diff)
downloadwireguard-go-7ee95e053c280796ecfb5533000915e7daa13f69.tar.xz
wireguard-go-7ee95e053c280796ecfb5533000915e7daa13f69.zip
device: remove QueueOutboundElement.dropped
If we block when enqueuing encryption elements to the queue, then we never drop them. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
-rw-r--r--device/send.go23
1 files changed, 0 insertions, 23 deletions
diff --git a/device/send.go b/device/send.go
index c9b62e6..1d27799 100644
--- a/device/send.go
+++ b/device/send.go
@@ -43,7 +43,6 @@ import (
*/
type QueueOutboundElement struct {
- dropped int32
sync.Mutex
buffer *[MaxMessageSize]byte // slice holding the packet data
packet []byte // slice of "buffer" (always!)
@@ -54,7 +53,6 @@ type QueueOutboundElement struct {
func (device *Device) NewOutboundElement() *QueueOutboundElement {
elem := device.GetOutboundElement()
- elem.dropped = AtomicFalse
elem.buffer = device.GetMessageBuffer()
elem.Mutex = sync.Mutex{}
elem.nonce = 0
@@ -73,14 +71,6 @@ func (elem *QueueOutboundElement) clearPointers() {
elem.peer = nil
}
-func (elem *QueueOutboundElement) Drop() {
- atomic.StoreInt32(&elem.dropped, AtomicTrue)
-}
-
-func (elem *QueueOutboundElement) IsDropped() bool {
- return atomic.LoadInt32(&elem.dropped) == AtomicTrue
-}
-
func addToNonceQueue(queue chan *QueueOutboundElement, elem *QueueOutboundElement, device *Device) {
for {
select {
@@ -436,7 +426,6 @@ NextPacket:
}
elem.keypair = keypair
- elem.dropped = AtomicFalse
elem.Lock()
// add to parallel and sequential queue
@@ -476,15 +465,7 @@ func (device *Device) RoutineEncryption() {
logDebug.Println("Routine: encryption worker - started")
for elem := range device.queue.encryption.c {
-
- // check if dropped
-
- if elem.IsDropped() {
- continue
- }
-
// populate header fields
-
header := elem.buffer[:MessageTransportHeaderSize]
fieldType := header[0:4]
@@ -532,10 +513,6 @@ func (peer *Peer) RoutineSequentialSender() {
for elem := range peer.queue.outbound {
elem.Lock()
- if elem.IsDropped() {
- device.PutOutboundElement(elem)
- continue
- }
if !peer.isRunning.Get() {
// peer has been stopped; return re-usable elems to the shared pool.
// This is an optimization only. It is possible for the peer to be stopped