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 <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-07-09 14:51:10 -07:00
Родитель 5f017bba48
Коммит 34ab8c4326
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -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)