mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix update endpoint cnt to store
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
parent
68e53443c9
commit
804f93bdff
1 changed files with 7 additions and 0 deletions
|
@ -113,6 +113,9 @@ func (ec *endpointCnt) updateStore() error {
|
|||
if store == nil {
|
||||
return fmt.Errorf("store not found for scope %s on endpoint count update", ec.DataScope())
|
||||
}
|
||||
// make a copy of count and n to avoid being overwritten by store.GetObject
|
||||
count := ec.EndpointCnt()
|
||||
n := ec.n
|
||||
for {
|
||||
if err := ec.n.getController().updateToStore(ec); err == nil || err != datastore.ErrKeyModified {
|
||||
return err
|
||||
|
@ -120,6 +123,10 @@ func (ec *endpointCnt) updateStore() error {
|
|||
if err := store.GetObject(datastore.Key(ec.Key()...), ec); err != nil {
|
||||
return fmt.Errorf("could not update the kvobject to latest on endpoint count update: %v", err)
|
||||
}
|
||||
ec.Lock()
|
||||
ec.Count = count
|
||||
ec.n = n
|
||||
ec.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue