mirror of https://github.com/hashicorp/consul
Fixed sync of Extra in binarySearch
parent
89ba5165f9
commit
728c5308df
|
@ -721,14 +721,17 @@ func syncExtra(index map[string]dns.RR, resp *dns.Msg) {
|
||||||
// it in order to return a DNS answer lower than maxSize parameter.
|
// it in order to return a DNS answer lower than maxSize parameter.
|
||||||
func dnsBinaryTruncate(resp *dns.Msg, maxSize int, index map[string]dns.RR, hasExtra bool) int {
|
func dnsBinaryTruncate(resp *dns.Msg, maxSize int, index map[string]dns.RR, hasExtra bool) int {
|
||||||
originalAnswser := resp.Answer
|
originalAnswser := resp.Answer
|
||||||
|
originalExtra := resp.Extra
|
||||||
|
originalIndex := index
|
||||||
startIndex := 0
|
startIndex := 0
|
||||||
endIndex := len(resp.Answer) + 1
|
endIndex := len(resp.Answer) + 1
|
||||||
for endIndex-startIndex > 1 {
|
for endIndex-startIndex > 1 {
|
||||||
median := startIndex + (endIndex-startIndex)/2
|
median := startIndex + (endIndex-startIndex)/2
|
||||||
|
|
||||||
resp.Answer = originalAnswser[:median]
|
resp.Answer = originalAnswser[:median]
|
||||||
resp.Extra = originalAnswser[:median]
|
|
||||||
if hasExtra {
|
if hasExtra {
|
||||||
|
resp.Extra = originalExtra[:median]
|
||||||
|
index := originalIndex
|
||||||
syncExtra(index, resp)
|
syncExtra(index, resp)
|
||||||
}
|
}
|
||||||
aLen := resp.Len()
|
aLen := resp.Len()
|
||||||
|
|
Loading…
Reference in New Issue