2
0
mirror of synced 2025-02-24 06:38:14 +00:00

Don't consider a peer to have touched a piece if a chunk isn't written successfully

This prevents peers being banned when there are issues with the data service locally.
This commit is contained in:
Matt Joiner 2015-12-11 03:04:04 +11:00
parent 8c37ff73af
commit 672e3c4136

View File

@ -2584,12 +2584,13 @@ func (me *Client) downloadedChunk(t *torrent, c *connection, msg *pp.Message) er
return
}
tr.Stop("write chunk")
me.mu.Lock()
if c.peerTouchedPieces == nil {
c.peerTouchedPieces = make(map[int]struct{})
}
c.peerTouchedPieces[int(req.Index)] = struct{}{}
me.mu.Unlock()
}()
// This could be made dependent on whether any actual data was written.
if c.peerTouchedPieces == nil {
c.peerTouchedPieces = make(map[int]struct{})
}
c.peerTouchedPieces[int(req.Index)] = struct{}{}
// log.Println("got chunk", req)
me.event.Broadcast()