@cryptotaxi247 / kubo / commits / e65afaf19

dont rate limit query during dials

Juan Batiz-Benet committed Jan 22, 2015 at 07:34 UTC e65afaf198177fe341c8568516aafe3ea524f53b
1 file changed +5 -1
routing/dht/query.go
+5 -1
@@ -223,6 +223,9 @@ func (r *dhtQueryRunner) queryPeer(cg ctxgroup.ContextGroup, p peer.ID) {
223 // make sure we're connected to the peer.
224 if conns := r.query.dht.host.Network().ConnsToPeer(p); len(conns) == 0 {
225 log.Infof("not connected. dialing.")
226 + // while we dial, we do not take up a rate limit. this is to allow
227 + // forward progress during potentially very high latency dials.
228 + r.rateLimit <- struct{}{}
229
230 pi := peer.PeerInfo{ID: p}
231 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) {
233 r.Lock()
234 r.errs = append(r.errs, err)
235 r.Unlock()
236 + <-r.rateLimit // need to grab it again, as we deferred.
237 return
238 }
235 -
239 + <-r.rateLimit // need to grab it again, as we deferred.
240 log.Debugf("connected. dial success.")
241 }
242