Skip to content

Commit

Permalink
Explicit sorting across priority levels
Browse files Browse the repository at this point in the history
There was a bug in the handling of prioritized host lists that caused
only the lowest priority level to be eligible for tophost.  This commit
amends the sorting and handling of the weighted lists so that it returns
the correct host.
  • Loading branch information
nugget committed Nov 30, 2017
1 parent 034eddf commit 8589dc6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dnssrv.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ namespace eval ::dnssrv {
return
}

proc apply_weightings {hostlist {_retlist retlist}} {
upvar 1 $_retlist retlist

proc weighted_list {hostlist} {
# This behavior is defined by RFC2782

set zero_weighted [list]
Expand Down Expand Up @@ -110,7 +108,7 @@ namespace eval ::dnssrv {
}
}

return
return $retlist
}

proc randomize_list {list} {
Expand Down Expand Up @@ -145,8 +143,8 @@ namespace eval ::dnssrv {
lappend pri($rdata(priority)) [list $rdata(weight) $target]
}

foreach priority [array names pri] {
apply_weightings $pri($priority) retlist
foreach priority [lsort -increasing -integer [array names pri]] {
set retlist [concat $retlist [weighted_list $pri($priority)]]
}

return $retlist
Expand Down

0 comments on commit 8589dc6

Please sign in to comment.