Add locking for the zone structure

This commit is contained in:
Miek Gieben 2012-08-25 20:19:13 +02:00
parent 23d4972158
commit 251af89dcc
1 changed files with 3 additions and 1 deletions

View File

@ -8,7 +8,7 @@ import (
"sync"
)
// Zone represents a DNS zone. Currently there is no locking implemented.
// Zone represents a DNS zone.
type Zone struct {
Origin string // Origin of the zone
Wildcard int // Whenever we see a wildcard name, this is incremented
@ -48,6 +48,7 @@ func NewZone(origin string) *Zone {
return nil
}
z := new(Zone)
z.mutex = new(sync.RWMutex)
z.Origin = Fqdn(origin)
z.Radix = radix.New()
return z
@ -73,6 +74,7 @@ func (z *Zone) Insert(r RR) error {
zd.Name = r.Header().Name
zd.RR = make(map[uint16][]RR)
zd.Signatures = make(map[uint16][]*RR_RRSIG)
zd.mutex = new(sync.RWMutex)
switch t := r.Header().Rrtype; t {
case TypeRRSIG:
sigtype := r.(*RR_RRSIG).TypeCovered