Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
dvovk committed Dec 5, 2024
1 parent 87998b5 commit 87d4028
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 1 addition & 3 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,7 @@ func (c *Peer) deleteRequest(r RequestIndex, lock bool, lockTorrent bool) bool {
defer c.mu.Unlock()
}

removed := c.requestState.Requests.CheckedRemove(r)

if !removed {
if !c.requestState.Requests.CheckedRemove(r) {
return false
}

Expand Down
9 changes: 2 additions & 7 deletions webseed-peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,13 @@ func requestUpdate(ws *webseedPeer) {
rate := p.downloadRate()
pieces := p.uncancelledRequests(false)
desired := p.desiredRequests(false)
banCount := p.banCount

this := ""
if p == &ws.peer {
this = "*"
}
flags := p.StatusFlags()
peerInfo = append(peerInfo, fmt.Sprintf("%s%s:p=%d,d=%d,bc=%d: %f", this, flags, pieces, desired, banCount, rate))
peerInfo = append(peerInfo, fmt.Sprintf("%s%s:p=%d,d=%d: %f", this, flags, pieces, desired, rate))

}, false)

Expand Down Expand Up @@ -573,8 +572,6 @@ func (ws *webseedPeer) requestResultHandler(r Request, webseedRequest *webseed.R
}

if ws.peer.t.closed.IsSet() {
//log
ws.peer.logger.Printf("closed %v", ws)
return nil
}

Expand All @@ -585,8 +582,6 @@ func (ws *webseedPeer) requestResultHandler(r Request, webseedRequest *webseed.R
err = result.Ctx.Err()
}

reqIdx := ws.peer.t.requestIndexFromRequest(r, true)

if err != nil {
switch {
case errors.Is(err, context.Canceled):
Expand All @@ -604,7 +599,7 @@ func (ws *webseedPeer) requestResultHandler(r Request, webseedRequest *webseed.R
}
}

if !ws.peer.remoteRejectedRequest(reqIdx, true, true) {
if !ws.peer.remoteRejectedRequest(ws.peer.t.requestIndexFromRequest(r, true), true, true) {
err = fmt.Errorf(`received invalid reject "%w", for request %v`, err, r)
ws.peer.logger.Levelf(log.Debug, "%v", err)
}
Expand Down

0 comments on commit 87d4028

Please sign in to comment.