Skip to content

Commit

Permalink
Merge pull request moby#5560 from gabrtv/deregister-containers-earlier
Browse files Browse the repository at this point in the history
De-register containers before removing driver and containerGraph references
  • Loading branch information
creack committed May 2, 2014
2 parents a0cef41 + 9f152aa commit 103d028
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ func (daemon *Daemon) Destroy(container *Container) error {
return err
}

// Deregister the container before removing its directory, to avoid race conditions
daemon.idIndex.Delete(container.ID)
daemon.containers.Remove(element)

if err := daemon.driver.Remove(container.ID); err != nil {
return fmt.Errorf("Driver %s failed to remove root filesystem %s: %s", daemon.driver, container.ID, err)
}
Expand All @@ -285,9 +289,6 @@ func (daemon *Daemon) Destroy(container *Container) error {
utils.Debugf("Unable to remove container from link graph: %s", err)
}

// Deregister the container before removing its directory, to avoid race conditions
daemon.idIndex.Delete(container.ID)
daemon.containers.Remove(element)
if err := os.RemoveAll(container.root); err != nil {
return fmt.Errorf("Unable to remove filesystem for %v: %v", container.ID, err)
}
Expand Down

0 comments on commit 103d028

Please sign in to comment.