read locking

This commit is contained in:
Miek Gieben 2012-08-25 22:12:29 +02:00
parent eaaef0af9d
commit 8d56ace2ed
1 changed files with 4 additions and 0 deletions

View File

@ -154,6 +154,8 @@ func (z *Zone) Remove(r RR) error {
// Find looks up the ownername s in the zone and returns the
// data when found or nil when nothing is found.
func (z *Zone) Find(s string) *ZoneData {
z.mutex.RLock()
defer z.mutex.RUnlock()
zd := z.Radix.Find(toRadixName(s))
if zd == nil {
return nil
@ -163,6 +165,8 @@ func (z *Zone) Find(s string) *ZoneData {
// Predecessor searches the zone for a name shorter than s.
func (z *Zone) Predecessor(s string) *ZoneData {
z.mutex.RLock()
defer z.mutex.RUnlock()
zd := z.Radix.Predecessor(toRadixName(s))
if zd == nil {
return nil