Limit outstanding requests
This commit is contained in:
parent
0830589b0a
commit
b2c68b314b
|
@ -533,6 +533,9 @@ func (cn *Peer) request(r Request) (more bool, err error) {
|
|||
if _, ok := cn.requests[r]; ok {
|
||||
return true, nil
|
||||
}
|
||||
if cn.numLocalRequests() >= cn.nominalMaxRequests() {
|
||||
return true, errors.New("too many outstanding requests")
|
||||
}
|
||||
if !cn.peerHasPiece(pieceIndex(r.Index)) {
|
||||
return true, errors.New("requesting piece peer doesn't have")
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/log"
|
||||
"github.com/anacrolix/multiless"
|
||||
pp "github.com/anacrolix/torrent/peer_protocol"
|
||||
"github.com/bradfitz/iter"
|
||||
|
@ -115,7 +114,7 @@ func (cl *Client) doRequests() {
|
|||
req := Request{pp.Integer(p.index), chunk}
|
||||
_, err := peer.request(req)
|
||||
if err == nil {
|
||||
log.Printf("requested %v", req)
|
||||
//log.Printf("requested %v", req)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue