Skip to content

Commit 477ce36

Browse files
committed
Support for RWMutex lock for zones to support updating dns records
Signed-off-by: Balaji Vijayakumar <[email protected]>
1 parent 689a54a commit 477ce36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/services/dns/dns.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import (
55
"fmt"
66
"net"
77
"strings"
8+
"sync"
89

910
"github.com/containers/gvisor-tap-vsock/pkg/types"
1011
"github.com/miekg/dns"
1112
log "github.com/sirupsen/logrus"
1213
)
1314

1415
type dnsHandler struct {
15-
zones []types.Zone
16+
zones []types.Zone
17+
zonesLock sync.RWMutex
1618
}
1719

1820
func (h *dnsHandler) handle(w dns.ResponseWriter, r *dns.Msg) {
@@ -26,6 +28,8 @@ func (h *dnsHandler) handle(w dns.ResponseWriter, r *dns.Msg) {
2628
}
2729

2830
func (h *dnsHandler) addAnswers(m *dns.Msg) {
31+
h.zonesLock.RLock()
32+
defer h.zonesLock.RUnlock()
2933
for _, q := range m.Question {
3034
for _, zone := range h.zones {
3135
zoneSuffix := fmt.Sprintf(".%s", zone.Name)

0 commit comments

Comments
 (0)