From 4fae1f81df36b8f5b5e5ff14e160b93ec6d5d6a4 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 23 Jan 2020 13:52:17 +1100 Subject: [PATCH] Record connection dirtied piece before queuing for hash Not a bug, but probably more robust. --- connection.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index 3a857d91..76c15d32 100644 --- a/connection.go +++ b/connection.go @@ -1400,13 +1400,13 @@ func (c *connection) receiveChunk(msg *pp.Message) error { return nil } + c.onDirtiedPiece(pieceIndex(req.Index)) + if t.pieceAllDirty(pieceIndex(req.Index)) { t.queuePieceCheck(pieceIndex(req.Index)) t.pendAllChunkSpecs(pieceIndex(req.Index)) } - c.onDirtiedPiece(pieceIndex(req.Index)) - cl.event.Broadcast() // We do this because we've written a chunk, and may change PieceState.Partial. t.publishPieceChange(pieceIndex(req.Index))