Skip to content

Commit 74fb5da

Browse files
author
livingentity
authored
fix negative rtt / shorten lines (#2118)
* fix negative rtt / shorten lines * Update serversInfo.go
1 parent 1afd573 commit 74fb5da

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

dnscrypt-proxy/serversInfo.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ func (serversInfo *ServersInfo) estimatorUpdate(currentActive int) {
263263
if currentActiveRtt < 0 {
264264
currentActiveRtt = candidateRtt
265265
serversInfo.inner[currentActive].rtt.Set(currentActiveRtt)
266+
return
266267
}
267268
partialSort := false
268269
if candidateRtt < currentActiveRtt {
@@ -277,7 +278,13 @@ func (serversInfo *ServersInfo) estimatorUpdate(currentActive int) {
277278
} else if candidateRtt > 0 && candidateRtt >= (serversInfo.inner[0].rtt.Value()+serversInfo.inner[activeCount-1].rtt.Value())/2.0*4.0 {
278279
if time.Since(serversInfo.inner[candidate].lastActionTS) > time.Duration(1*time.Minute) {
279280
serversInfo.inner[candidate].rtt.Add(candidateRtt / 2.0)
280-
dlog.Debugf("Giving a new chance to candidate [%s], lowering its RTT from %d to %d (best: %d)", serversInfo.inner[candidate].Name, int(candidateRtt), int(serversInfo.inner[candidate].rtt.Value()), int(serversInfo.inner[0].rtt.Value()))
281+
dlog.Debugf(
282+
"Giving a new chance to candidate [%s], lowering its RTT from %d to %d (best: %d)",
283+
serversInfo.inner[candidate].Name,
284+
int(candidateRtt),
285+
int(serversInfo.inner[candidate].rtt.Value()),
286+
int(serversInfo.inner[0].rtt.Value()),
287+
)
281288
partialSort = true
282289
}
283290
}

0 commit comments

Comments
 (0)