Retain interest if requests are outstanding and don't clear peer requests if they send not_interested
Apparent shortcomings found when trying new request algorithms.
This commit is contained in:
parent
159c4a0e28
commit
ad03e64722
|
@ -591,6 +591,9 @@ func nextRequestState(
|
||||||
if len(currentRequests) > requestsLowWater {
|
if len(currentRequests) > requestsLowWater {
|
||||||
return false, nil, true
|
return false, nil, true
|
||||||
}
|
}
|
||||||
|
// If we have existing requests, better maintain interest to ensure we get
|
||||||
|
// them. iterPendingRequests might not iterate over outstanding requests.
|
||||||
|
interested = len(currentRequests) != 0
|
||||||
iterPendingRequests(func(r request) bool {
|
iterPendingRequests(func(r request) bool {
|
||||||
interested = true
|
interested = true
|
||||||
if peerChoking {
|
if peerChoking {
|
||||||
|
@ -1040,8 +1043,9 @@ func (c *connection) mainReadLoop() (err error) {
|
||||||
c.tickleWriter()
|
c.tickleWriter()
|
||||||
case pp.NotInterested:
|
case pp.NotInterested:
|
||||||
c.PeerInterested = false
|
c.PeerInterested = false
|
||||||
// TODO: Reject?
|
// We don't clear their requests since it isn't clear in the spec.
|
||||||
c.PeerRequests = nil
|
// We'll probably choke them for this, which will clear them if
|
||||||
|
// appropriate, and is clearly specified.
|
||||||
case pp.Have:
|
case pp.Have:
|
||||||
err = c.peerSentHave(int(msg.Index))
|
err = c.peerSentHave(int(msg.Index))
|
||||||
case pp.Request:
|
case pp.Request:
|
||||||
|
|
Loading…
Reference in New Issue