Check if torrent is closed before handling peer request data read failures
Should fix panics using storage after its been closed, like in https://github.com/anacrolix/torrent/runs/4017475163.
This commit is contained in:
parent
eb2fc6dbef
commit
f2e9eeba3b
|
@ -984,6 +984,9 @@ func (c *PeerConn) peerRequestDataReader(r Request, prs *peerRequestState) {
|
|||
// chunk sending, the way it used to work.
|
||||
func (c *PeerConn) peerRequestDataReadFailed(err error, r Request) {
|
||||
c.logger.WithDefaultLevel(log.Warning).Printf("error reading chunk for peer Request %v: %v", r, err)
|
||||
if c.t.closed.IsSet() {
|
||||
return
|
||||
}
|
||||
i := pieceIndex(r.Index)
|
||||
if c.t.pieceComplete(i) {
|
||||
// There used to be more code here that just duplicated the following break. Piece
|
||||
|
|
Loading…
Reference in New Issue