Fix a race in the endpoint.go

This commit is contained in:
vikaschoudhary16 2017-12-23 03:02:33 -05:00
parent 572e276493
commit cc4d2cbe9d

View File

@ -164,7 +164,11 @@ func (e *endpointImpl) run() {
}
e.mutex.Lock()
e.devices = devices
// NOTE: Return a copy of 'devices' instead of returning a direct reference to local 'devices'
e.devices = make(map[string]pluginapi.Device)
for _, d := range devices {
e.devices[d.ID] = d
}
e.mutex.Unlock()
e.callback(e.resourceName, added, updated, deleted)