mirror of
https://github.com/netbirdio/netbird.git
synced 2025-01-09 15:38:26 +01:00
[client] Reduce DNS handler chain lock contention (#3099)
This commit is contained in:
parent
7ee7ada273
commit
b48cf1bf65
@ -1,6 +1,7 @@
|
|||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -161,16 +162,19 @@ func (c *HandlerChain) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
log.Tracef("handling DNS request for domain=%s", qname)
|
log.Tracef("handling DNS request for domain=%s", qname)
|
||||||
|
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
handlers := slices.Clone(c.handlers)
|
||||||
|
c.mu.RUnlock()
|
||||||
|
|
||||||
log.Tracef("current handlers (%d):", len(c.handlers))
|
if log.IsLevelEnabled(log.TraceLevel) {
|
||||||
for _, h := range c.handlers {
|
log.Tracef("current handlers (%d):", len(handlers))
|
||||||
|
for _, h := range handlers {
|
||||||
log.Tracef(" - pattern: domain=%s original: domain=%s wildcard=%v priority=%d",
|
log.Tracef(" - pattern: domain=%s original: domain=%s wildcard=%v priority=%d",
|
||||||
h.Pattern, h.OrigPattern, h.IsWildcard, h.Priority)
|
h.Pattern, h.OrigPattern, h.IsWildcard, h.Priority)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try handlers in priority order
|
// Try handlers in priority order
|
||||||
for _, entry := range c.handlers {
|
for _, entry := range handlers {
|
||||||
var matched bool
|
var matched bool
|
||||||
switch {
|
switch {
|
||||||
case entry.Pattern == ".":
|
case entry.Pattern == ".":
|
||||||
|
Loading…
Reference in New Issue
Block a user