Skip to content

Commit

Permalink
Adjust preferred_hosts implementation
Browse files Browse the repository at this point in the history
Use 0 as the reported ping time for hosts in preferred_hosts, since the
previously used value of 1 is not guaranteed to be lower than hosts
that respond extremely quickly. 0 was previously used to indicate no
entry in the cache, so switch to using the empty string for that.

Closes: #351
(cherry picked from commit ed1bda2)
  • Loading branch information
jmroot committed Oct 23, 2024
1 parent 9fd2acc commit f3badd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/macports1.0/macports.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -6273,13 +6273,13 @@ proc macports::get_pingtime {host} {
variable preferred_hosts
foreach pattern $preferred_hosts {
if {[string match -nocase $pattern $host]} {
dict set host_cache $host 1
return 1
dict set host_cache $host 0
return 0
}
}
dict set host_cache $host 0
dict set host_cache $host {}
}
if {[dict get $host_cache $host] != 0} {
if {[dict get $host_cache $host] ne {}} {
return [dict get $host_cache $host]
}

Expand Down
2 changes: 1 addition & 1 deletion src/macports1.0/tests/macports.test
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ test get_pingtime {
if {[macports::get_pingtime macports_blacklist] != -1} {
return "FAIL: wrong time for blacklisted host"
}
if {[macports::get_pingtime macports_pref] != 1} {
if {[macports::get_pingtime macports_pref] != 0} {
return "FAIL: wrong time for preferred host"
}
return "Get ping time successful."
Expand Down

0 comments on commit f3badd5

Please sign in to comment.