Increase request update interval if there's no signalling
This commit is contained in:
parent
7096da9f03
commit
d42f2516a4
10
client.go
10
client.go
|
@ -53,7 +53,7 @@ type Client struct {
|
|||
|
||||
_mu lockWithDeferreds
|
||||
event sync.Cond
|
||||
closed missinggo.Event
|
||||
closed chansync.SetOnce
|
||||
|
||||
config *ClientConfig
|
||||
logger log.Logger
|
||||
|
@ -398,10 +398,8 @@ func (cl *Client) NewAnacrolixDhtServer(conn net.PacketConn) (s *dht.Server, err
|
|||
return
|
||||
}
|
||||
|
||||
func (cl *Client) Closed() <-chan struct{} {
|
||||
cl.lock()
|
||||
defer cl.unlock()
|
||||
return cl.closed.C()
|
||||
func (cl *Client) Closed() chansync.Done {
|
||||
return cl.closed.Done()
|
||||
}
|
||||
|
||||
func (cl *Client) eachDhtServer(f func(DhtServer)) {
|
||||
|
@ -1518,7 +1516,7 @@ func (cl *Client) clearAcceptLimits() {
|
|||
func (cl *Client) acceptLimitClearer() {
|
||||
for {
|
||||
select {
|
||||
case <-cl.closed.LockedChan(cl.locker()):
|
||||
case <-cl.closed.Done():
|
||||
return
|
||||
case <-time.After(15 * time.Minute):
|
||||
cl.lock()
|
||||
|
|
|
@ -1297,6 +1297,7 @@ func (c *Peer) receiveChunk(msg *pp.Message) error {
|
|||
c.allStats(add(int64(len(msg.Piece)), func(cs *ConnStats) *Count { return &cs.BytesReadUsefulData }))
|
||||
if deletedRequest {
|
||||
c.piecesReceivedSinceLastRequestUpdate++
|
||||
c.updateRequests()
|
||||
c.allStats(add(int64(len(msg.Piece)), func(cs *ConnStats) *Count { return &cs.BytesReadUsefulIntendedData }))
|
||||
}
|
||||
for _, f := range c.t.cl.config.Callbacks.ReceivedUsefulData {
|
||||
|
|
|
@ -19,14 +19,16 @@ func (cl *Client) requester() {
|
|||
cl.doRequests()
|
||||
return cl.updateRequests.Signaled()
|
||||
}()
|
||||
// We can probably tune how often to heed this signal. TODO: Currently disabled to retain
|
||||
// existing behaviour, while the signalling is worked out.
|
||||
update = nil
|
||||
select {
|
||||
case <-cl.closed.LockedChan(cl.locker()):
|
||||
case <-cl.closed.Done():
|
||||
return
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
}
|
||||
select {
|
||||
case <-cl.closed.Done():
|
||||
return
|
||||
case <-update:
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue