mirror of https://github.com/status-im/consul.git
Optimize size for SRV records, should improve performance a bit
Stricter Unit tests that checks if truncation was OK.
This commit is contained in:
parent
d0e45f22df
commit
93fa1f6f49
|
@ -732,8 +732,12 @@ func (d *DNSServer) trimTCPResponse(req, resp *dns.Msg) (trimmed bool) {
|
|||
// Beyond 2500 records, performance gets bad
|
||||
// Limit the number of records at once, anyway, it won't fit in 64k
|
||||
// For SRV Records, the max is around 500 records, for A, less than 2k
|
||||
if len(resp.Answer) > 2048 {
|
||||
resp.Answer = resp.Answer[:2048]
|
||||
truncateAt := 2048
|
||||
if req.Question[0].Qtype == dns.TypeSRV {
|
||||
truncateAt = 640
|
||||
}
|
||||
if len(resp.Answer) > truncateAt {
|
||||
resp.Answer = resp.Answer[:truncateAt]
|
||||
}
|
||||
if hasExtra {
|
||||
index = make(map[string]dns.RR, len(resp.Extra))
|
||||
|
|
|
@ -2818,9 +2818,9 @@ func TestDNS_TCP_and_UDP_Truncate(t *testing.T) {
|
|||
// Check for the truncate bit
|
||||
shouldBeTruncated := numServices > 4095
|
||||
|
||||
if shouldBeTruncated != in.Truncated {
|
||||
info := fmt.Sprintf("service %s question:=%s (%s) (%d total records) in %v",
|
||||
service, question, protocol, numServices, out)
|
||||
if shouldBeTruncated != in.Truncated || len(in.Answer) > 2000 || len(in.Answer) < 1 || in.Len() > 65535 {
|
||||
info := fmt.Sprintf("service %s question:=%s (%s) (%d total records) sz:= %d in %v",
|
||||
service, question, protocol, numServices, len(in.Answer), out)
|
||||
t.Fatalf("Should have truncate:=%v for %s", shouldBeTruncated, info)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue