]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Count failed chunk sends against a connection
authorMatt Joiner <anacrolix@gmail.com>
Thu, 17 Sep 2015 02:50:29 +0000 (12:50 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 17 Sep 2015 02:50:29 +0000 (12:50 +1000)
client.go

index 16782a9c4edac074627534d312db7b9e75312561..5caaf76a5d2c23a24112cd5711ee14069af8e16a 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1448,6 +1448,8 @@ another:
 }
 
 func (me *Client) sendChunk(t *torrent, c *connection, r request) error {
+       // Count the chunk being sent, even if it isn't.
+       c.chunksSent++
        b := make([]byte, r.Length)
        tp := t.Pieces[r.Index]
        tp.pendingWritesMutex.Lock()
@@ -1470,7 +1472,6 @@ func (me *Client) sendChunk(t *torrent, c *connection, r request) error {
                Piece: b,
        })
        uploadChunksPosted.Add(1)
-       c.chunksSent++
        c.lastChunkSent = time.Now()
        return nil
 }