Skip to content

Commit ec0e60e

Browse files
committed
Fix some races in getNetworkFromStore
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
1 parent d1a195a commit ec0e60e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ func (ep *endpoint) getNetworkFromStore() (*network, error) {
343343
return nil, fmt.Errorf("invalid network object in endpoint %s", ep.Name())
344344
}
345345

346-
return ep.network.ctrlr.getNetworkFromStore(ep.network.id)
346+
return ep.network.getController().getNetworkFromStore(ep.network.id)
347347
}
348348

349349
func (ep *endpoint) Join(sbox Sandbox, options ...EndpointOption) error {

store.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
141141
return nil, fmt.Errorf("could not find endpoint count key %s for network %s while listing: %v", datastore.Key(ec.Key()...), n.Name(), err)
142142
}
143143

144+
n.Lock()
144145
n.epCnt = ec
145146
n.scope = store.Scope()
147+
n.Unlock()
146148
nl = append(nl, n)
147149
}
148150
}

0 commit comments

Comments
 (0)