On network disconnect clear the cached connections to external

nameservers

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
This commit is contained in:
Santhosh Manohar 2016-03-20 05:00:58 -07:00
parent 7b30f71c18
commit ca06f1ed80
2 changed files with 14 additions and 2 deletions

View file

@ -547,6 +547,10 @@ func (ep *endpoint) Leave(sbox Sandbox, options ...EndpointOption) error {
sb.joinLeaveStart()
defer sb.joinLeaveEnd()
if sb.resolver != nil {
sb.resolver.FlushExtServers()
}
return ep.sbLeave(sb, false, options...)
}

View file

@ -28,8 +28,12 @@ type Resolver interface {
// NameServer() returns the IP of the DNS resolver for the
// containers.
NameServer() string
// To configure external name servers the resolver should use
// SetExtServers configures the external nameservers the resolver
// should use to forward queries
SetExtServers([]string)
// FlushExtServers clears the cached UDP connections to external
// nameservers
FlushExtServers()
// ResolverOptions returns resolv.conf options that should be set
ResolverOptions() []string
}
@ -139,11 +143,15 @@ func (r *resolver) Start() error {
return nil
}
func (r *resolver) Stop() {
func (r *resolver) FlushExtServers() {
for i := 0; i < maxExtDNS; i++ {
r.extDNSList[i].extConn = nil
r.extDNSList[i].extOnce = sync.Once{}
}
}
func (r *resolver) Stop() {
r.FlushExtServers()
if r.server != nil {
r.server.Shutdown()