From: Matt Joiner Date: Mon, 18 Sep 2017 03:47:49 +0000 (+1000) Subject: Also post cancels X-Git-Tag: v1.0.0~378 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=67e96686d27bbec9713746c5fdb7b28229f565f2;p=btrtrc.git 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. --- 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 +}