1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #1024 from mavenugo/loc

Fixing a possible endpoint_cnt state inconsistency issue
This commit is contained in:
Alessandro Boch 2016-03-16 09:57:06 -07:00
commit b38b52c6b4
2 changed files with 19 additions and 0 deletions

View file

@ -1000,5 +1000,17 @@ func (c *controller) cleanupLocalEndpoints() {
log.Warnf("Could not delete local endpoint %s during endpoint cleanup: %v", ep.name, err) log.Warnf("Could not delete local endpoint %s during endpoint cleanup: %v", ep.name, err)
} }
} }
epl, err = n.getEndpointsFromStore()
if err != nil {
log.Warnf("Could not get list of endpoints in network %s for count update: %v", n.name, err)
continue
}
epCnt := n.getEpCnt().EndpointCnt()
if epCnt != uint64(len(epl)) {
log.Warnf("Inconsistent endpoint_cnt for network %s. Expected=%d, Actual=%d", n.name, len(epl), epCnt)
n.getEpCnt().setCnt(uint64(len(epl)))
}
} }
} }

View file

@ -123,6 +123,13 @@ func (ec *endpointCnt) updateStore() error {
} }
} }
func (ec *endpointCnt) setCnt(cnt uint64) error {
ec.Lock()
ec.Count = cnt
ec.Unlock()
return ec.updateStore()
}
func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error { func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error {
retry: retry:
ec.Lock() ec.Lock()