Commit 356dcff8 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet Committed by Jeromy

dont rate limit query during dials

parent 2c2de4d9
...@@ -223,6 +223,9 @@ func (r *dhtQueryRunner) queryPeer(cg ctxgroup.ContextGroup, p peer.ID) { ...@@ -223,6 +223,9 @@ func (r *dhtQueryRunner) queryPeer(cg ctxgroup.ContextGroup, p peer.ID) {
// make sure we're connected to the peer. // make sure we're connected to the peer.
if conns := r.query.dht.host.Network().ConnsToPeer(p); len(conns) == 0 { if conns := r.query.dht.host.Network().ConnsToPeer(p); len(conns) == 0 {
log.Infof("not connected. dialing.") log.Infof("not connected. dialing.")
// while we dial, we do not take up a rate limit. this is to allow
// forward progress during potentially very high latency dials.
r.rateLimit <- struct{}{}
pi := peer.PeerInfo{ID: p} pi := peer.PeerInfo{ID: p}
if err := r.query.dht.host.Connect(cg.Context(), pi); err != nil { if err := r.query.dht.host.Connect(cg.Context(), pi); err != nil {
...@@ -230,9 +233,10 @@ func (r *dhtQueryRunner) queryPeer(cg ctxgroup.ContextGroup, p peer.ID) { ...@@ -230,9 +233,10 @@ func (r *dhtQueryRunner) queryPeer(cg ctxgroup.ContextGroup, p peer.ID) {
r.Lock() r.Lock()
r.errs = append(r.errs, err) r.errs = append(r.errs, err)
r.Unlock() r.Unlock()
<-r.rateLimit // need to grab it again, as we deferred.
return return
} }
<-r.rateLimit // need to grab it again, as we deferred.
log.Debugf("connected. dial success.") log.Debugf("connected. dial success.")
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment