Check if Torrent is closed before receiving webseed chunks

This commit is contained in:
Matt Joiner 2021-12-03 21:31:16 +11:00
parent a9373fc8fd
commit 56bb8a9713
1 changed files with 3 additions and 0 deletions

View File

@ -132,6 +132,9 @@ func (ws *webseedPeer) requestResultHandler(r Request, webseedRequest webseed.Re
ws.peer.readBytes(int64(len(result.Bytes)))
ws.peer.t.cl.lock()
defer ws.peer.t.cl.unlock()
if ws.peer.t.closed.IsSet() {
return
}
if result.Err != nil {
if !errors.Is(result.Err, context.Canceled) && !ws.peer.closed.IsSet() {
ws.peer.logger.Printf("Request %v rejected: %v", r, result.Err)