Fix nil pointer reference in ServeDNS() with concurrent go routines.

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
This commit is contained in:
Santhosh Manohar 2016-03-15 02:05:38 -07:00
parent 9a91bbeb4f
commit 4e2e0f148b
1 changed files with 7 additions and 0 deletions

View File

@ -324,6 +324,13 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
continue
}
}
// If two go routines are executing in parralel one will
// block on the Once.Do and in case of error connecting
// to the external server it will end up with a nil err
// but extConn also being nil.
if extConn == nil {
continue
}
// Timeout has to be set for every IO operation.
extConn.SetDeadline(time.Now().Add(extIOTimeout))