compare_pingtimes: always use time if known

A stale entry with a lower ping time should be preferred to an entry
with a higher ping time that happens to have been refreshed recently.
So don't decide on status alone if both entries have a time.
This commit is contained in:
Joshua Root
2026-04-10 02:06:01 +10:00
parent 6dde22ecb2
commit fd1e224464
+8 -6
View File
@@ -7212,13 +7212,15 @@ proc macports::compare_pingtimes {a b} {
}
lassign [get_pingtime [dict get $a_parts host]] a_status a_pingtime
lassign [get_pingtime [dict get $b_parts host]] b_status b_pingtime
if {($a_status != 1 || $b_status != 1) && !($a_status == 0 && $b_status == 0)} {
# not both stale and at least one not cached and fresh, best status wins
return [expr {$b_status - $a_status}]
if {$a_pingtime ne {} && $b_pingtime ne {}} {
# compare actual ping times (make sure to return an integer)
set result [expr {round($a_pingtime - $b_pingtime)}]
if {$result != 0} {
return $result
}
}
# compare actual ping times (make sure to return an integer)
return [expr {round($a_pingtime - $b_pingtime)}]
# for ties or unknown times, status is all that counts
return [expr {$b_status - $a_status}]
}
# Deferred loading of compiler version cache