Update peer cancel assumptions and return
This commit is contained in:
parent
1b92249f2a
commit
aca22a0896
|
@ -17,9 +17,8 @@ type peerImpl interface {
|
|||
|
||||
// Neither of these return buffer room anymore, because they're currently both posted. There's
|
||||
// also PeerConn.writeBufferFull for when/where it matters.
|
||||
_cancel(RequestIndex) bool
|
||||
_cancel(RequestIndex)
|
||||
_request(Request) bool
|
||||
|
||||
connectionFlags() string
|
||||
onClose()
|
||||
onGotInfo(*metainfo.Info)
|
||||
|
|
18
peerconn.go
18
peerconn.go
|
@ -638,17 +638,17 @@ func (me *PeerConn) _request(r Request) bool {
|
|||
})
|
||||
}
|
||||
|
||||
func (me *Peer) cancel(r RequestIndex) bool {
|
||||
func (me *Peer) cancel(r RequestIndex) {
|
||||
if !me.actualRequestState.Requests.Contains(r) {
|
||||
return true
|
||||
panic(r)
|
||||
}
|
||||
return me._cancel(r)
|
||||
me._cancel(r)
|
||||
}
|
||||
|
||||
func (me *PeerConn) _cancel(r RequestIndex) bool {
|
||||
func (me *PeerConn) _cancel(r RequestIndex) {
|
||||
if me.cancelledRequests.Contains(r) {
|
||||
// Already cancelled and waiting for a response.
|
||||
return true
|
||||
panic(r)
|
||||
}
|
||||
// Transmission does not send rejects for received cancels. See
|
||||
// https://github.com/transmission/transmission/pull/2275.
|
||||
|
@ -662,7 +662,7 @@ func (me *PeerConn) _cancel(r RequestIndex) bool {
|
|||
me.updateRequests("Peer.cancel")
|
||||
}
|
||||
}
|
||||
return me.write(makeCancelMessage(me.t.requestIndexToRequest(r)))
|
||||
me.write(makeCancelMessage(me.t.requestIndexToRequest(r)))
|
||||
}
|
||||
|
||||
func (cn *PeerConn) fillWriteBuffer() {
|
||||
|
@ -1395,12 +1395,12 @@ func (c *Peer) receiveChunk(msg *pp.Message) error {
|
|||
piece.unpendChunkIndex(chunkIndexFromChunkSpec(ppReq.ChunkSpec, t.chunkSize))
|
||||
|
||||
// Cancel pending requests for this chunk from *other* peers.
|
||||
t.iterPeers(func(p *Peer) {
|
||||
if p := t.pendingRequests[req]; p != nil {
|
||||
if p == c {
|
||||
return
|
||||
panic("should not be pending request from conn that just received it")
|
||||
}
|
||||
p.cancel(req)
|
||||
})
|
||||
}
|
||||
|
||||
err := func() error {
|
||||
cl.unlock()
|
||||
|
|
|
@ -48,7 +48,7 @@ func (ws *webseedPeer) writeInterested(interested bool) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (ws *webseedPeer) _cancel(r RequestIndex) bool {
|
||||
func (ws *webseedPeer) _cancel(r RequestIndex) {
|
||||
active, ok := ws.activeRequests[ws.peer.t.requestIndexToRequest(r)]
|
||||
if ok {
|
||||
active.Cancel()
|
||||
|
@ -59,7 +59,6 @@ func (ws *webseedPeer) _cancel(r RequestIndex) bool {
|
|||
if ws.peer.isLowOnRequests() {
|
||||
ws.peer.updateRequests("webseedPeer._cancel")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (ws *webseedPeer) intoSpec(r Request) webseed.RequestSpec {
|
||||
|
|
Loading…
Reference in New Issue