]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Also post cancels
authorMatt Joiner <anacrolix@gmail.com>
Mon, 18 Sep 2017 03:47:49 +0000 (13:47 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 18 Sep 2017 03:47:49 +0000 (13:47 +1000)
Should mean that we don't have to wait for the peer requests low water mark before we process chunks to cancel.

connection.go

index c5c6c95743132debd5daec1457a04678b846c943..1d99664af7ab8b1652a5a27e804a53fbabcbf34d 100644 (file)
@@ -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
+}