From 34ab8c432691934745d66ee94ff4aec1120518e0 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 9 Jul 2015 14:51:10 -0700 Subject: [PATCH] Use mark and sweep for exec command removal This takes the final removal for exec commands in two steps. The first GC tick will mark the exec commands for removal and then the second tick will remove the config from the daemon. Signed-off-by: Michael Crosby --- daemon/exec.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/daemon/exec.go b/daemon/exec.go index 8ee7c1787..82e267bc2 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -28,6 +28,7 @@ type execConfig struct { OpenStderr bool OpenStdout bool Container *Container + canRemove bool } type execStore struct { @@ -256,12 +257,15 @@ func (d *Daemon) execCommandGC() { var ( cleaned int liveExecCommands = d.containerExecIds() - ids = d.execCommands.List() ) - for _, id := range ids { - if _, exists := liveExecCommands[id]; !exists { + for id, config := range d.execCommands.s { + if config.canRemove { cleaned++ d.execCommands.Delete(id) + } else { + if _, exists := liveExecCommands[id]; !exists { + config.canRemove = true + } } } logrus.Debugf("clean %d unused exec commands", cleaned)