From 67e96686d27bbec9713746c5fdb7b28229f565f2 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 18 Sep 2017 13:47:49 +1000 Subject: [PATCH] Also post cancels Should mean that we don't have to wait for the peer requests low water mark before we process chunks to cancel. --- connection.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/connection.go b/connection.go index c5c6c957..1d99664a 100644 --- a/connection.go +++ b/connection.go @@ -975,7 +975,7 @@ func (c *connection) receiveChunk(msg *pp.Message) { // Cancel pending requests for this chunk. for c := range t.conns { - c.updateRequests() + c.postCancel(req) } cl.mu.Unlock() @@ -1103,3 +1103,11 @@ func (c *connection) deleteRequest(r request) bool { func (c *connection) tickleWriter() { c.writerCond.Broadcast() } + +func (c *connection) postCancel(r request) bool { + if !c.deleteRequest(r) { + return false + } + c.Post(makeCancelMessage(r)) + return true +} -- 2.48.1