Fix some races in getNetworkFromStore

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2016-01-29 10:29:18 -08:00
parent 16efd61364
commit 74cf622463
2 changed files with 3 additions and 1 deletions

View File

@ -343,7 +343,7 @@ func (ep *endpoint) getNetworkFromStore() (*network, error) {
return nil, fmt.Errorf("invalid network object in endpoint %s", ep.Name())
}
return ep.network.ctrlr.getNetworkFromStore(ep.network.id)
return ep.network.getController().getNetworkFromStore(ep.network.id)
}
func (ep *endpoint) Join(sbox Sandbox, options ...EndpointOption) error {

View File

@ -141,8 +141,10 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
return nil, fmt.Errorf("could not find endpoint count key %s for network %s while listing: %v", datastore.Key(ec.Key()...), n.Name(), err)
}
n.Lock()
n.epCnt = ec
n.scope = store.Scope()
n.Unlock()
nl = append(nl, n)
}
}