Fix a race in the endpoint.go

pull/6/head
vikaschoudhary16 2017-12-23 03:02:33 -05:00
parent 572e276493
commit cc4d2cbe9d
1 changed files with 5 additions and 1 deletions

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)