From d43b93f60a771566280d34bc058f42b48f168ae6 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 17 May 2020 13:23:15 -0500 Subject: [PATCH] safer check for the queues if we're blocked on a send, should work even if we're blocked on a link packet send --- src/yggdrasil/link.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/link.go b/src/yggdrasil/link.go index 5676ebe..a0ce5d8 100644 --- a/src/yggdrasil/link.go +++ b/src/yggdrasil/link.go @@ -63,6 +63,7 @@ type linkInterface struct { stallTimer *time.Timer // Fires to signal that no incoming traffic (including keep-alive) has been seen closeTimer *time.Timer // Fires when the link has been idle so long we need to close it isIdle bool // True if the peer actor knows the link is idle + isSending bool // True between a notifySending and a notifySent blocked bool // True if we've blocked the peer in the switch } @@ -296,7 +297,7 @@ func (intf *linkInterface) linkOut(bs []byte) { func (intf *linkInterface) notifyQueued(seq uint64) { // This is the part where we want non-nil 'from' fields intf.Act(intf.peer, func() { - if !intf.isIdle { + if intf.isSending { intf.peer.dropFromQueue(intf, seq) } }) @@ -336,6 +337,7 @@ func (intf *linkInterface) notifySending(size int, isLinkTraffic bool) { if !isLinkTraffic { intf.isIdle = false } + intf.isSending = true intf.sendTimer = time.AfterFunc(sendTime, intf.notifyBlockedSend) intf._cancelStallTimer() }) @@ -370,6 +372,7 @@ func (intf *linkInterface) notifySent(size int, isLinkTraffic bool) { if !isLinkTraffic { intf._notifyIdle() } + intf.isSending = false if size > 0 && intf.stallTimer == nil { intf.stallTimer = time.AfterFunc(stallTime, intf.notifyStalled) }