dnsforward library -- Fix race conditions found by -race
This commit is contained in:
parent
ea1353422f
commit
639b34c7d1
|
@ -185,19 +185,23 @@ func (s *Server) reconfigureListenAddr(new ServerConfig) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errorx.Decorate(err, "Couldn't bind to %v", newAddr)
|
return errorx.Decorate(err, "Couldn't bind to %v", newAddr)
|
||||||
}
|
}
|
||||||
|
s.Lock()
|
||||||
if s.udpListen != nil {
|
if s.udpListen != nil {
|
||||||
err := s.udpListen.Close()
|
err = s.udpListen.Close()
|
||||||
if err != nil {
|
}
|
||||||
return errorx.Decorate(err, "Couldn't close UDP listening socket")
|
s.Unlock()
|
||||||
}
|
if err != nil {
|
||||||
|
return errorx.Decorate(err, "Couldn't close UDP listening socket")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Rebinding -- ports are same so close first then bind")
|
log.Printf("Rebinding -- ports are same so close first then bind")
|
||||||
|
s.Lock()
|
||||||
if s.udpListen != nil {
|
if s.udpListen != nil {
|
||||||
err := s.udpListen.Close()
|
err = s.udpListen.Close()
|
||||||
if err != nil {
|
}
|
||||||
return errorx.Decorate(err, "Couldn't close UDP listening socket")
|
s.Unlock()
|
||||||
}
|
if err != nil {
|
||||||
|
return errorx.Decorate(err, "Couldn't close UDP listening socket")
|
||||||
}
|
}
|
||||||
newListen, err = net.ListenUDP("udp", newAddr)
|
newListen, err = net.ListenUDP("udp", newAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue