Maintain container-by-pid index correctly.

This commit is contained in:
Tom Wilkie
2015-11-13 12:02:18 +00:00
committed by Paul Bellamy
parent 23be0d9aa9
commit 78c86372c8

View File

@@ -252,11 +252,17 @@ func (r *registry) updateContainerState(containerID string) {
if !ok {
c = NewContainerStub(dockerContainer)
r.containers[containerID] = c
r.containersByPID[dockerContainer.State.Pid] = c
} else {
// potentially remove existing pid mapping.
delete(r.containersByPID, c.PID())
c.UpdateState(dockerContainer)
}
// Update PID index
if c.PID() > 1 {
r.containersByPID[c.PID()] = c
}
// Trigger anyone watching for updates
for _, f := range r.watchers {
f(c)