Merge maxRequests into localClientReqq
This commit is contained in:
parent
42bf6b58a6
commit
86524214f5
|
@ -969,8 +969,9 @@ func (cl *Client) runHandshookConn(c *PeerConn, t *Torrent) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// If peer requests are buffered on read, this instructs the amount of memory that might be used to
|
||||
// cache pending writes. Assuming 512KiB cached for sending, for 16KiB chunks.
|
||||
// Maximum pending requests we allow peers to send us. If peer requests are buffered on read, this
|
||||
// instructs the amount of memory that might be used to cache pending writes. Assuming 512KiB
|
||||
// (1<<19) cached for sending, for 16KiB (1<<14) chunks.
|
||||
const localClientReqq = 1 << 5
|
||||
|
||||
// See the order given in Transmission's tr_peerMsgsNew.
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
|
||||
const (
|
||||
pieceHash = crypto.SHA1
|
||||
maxRequests = 250 // Maximum pending requests we allow peers to send us.
|
||||
defaultChunkSize = 0x4000 // 16KiB
|
||||
)
|
||||
|
||||
|
|
|
@ -989,7 +989,8 @@ func (c *PeerConn) onReadRequest(r Request) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
if len(c.peerRequests) >= maxRequests {
|
||||
// TODO: What if they've already requested this?
|
||||
if len(c.peerRequests) >= localClientReqq {
|
||||
torrent.Add("requests received while queue full", 1)
|
||||
if c.fastEnabled() {
|
||||
c.reject(r)
|
||||
|
@ -1010,7 +1011,7 @@ func (c *PeerConn) onReadRequest(r Request) error {
|
|||
return errors.New("bad Request")
|
||||
}
|
||||
if c.peerRequests == nil {
|
||||
c.peerRequests = make(map[Request]*peerRequestState, maxRequests)
|
||||
c.peerRequests = make(map[Request]*peerRequestState, localClientReqq)
|
||||
}
|
||||
value := &peerRequestState{}
|
||||
c.peerRequests[r] = value
|
||||
|
|
Loading…
Reference in New Issue