浏览代码

Merge pull request #19447 from sillyousu/19407-fix-exec-store-data-race

Fix race condition in execCommandGC
Doug Davis 9 年之前
父节点
当前提交
bdcc3ebe41
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      daemon/exec/exec.go

+ 7 - 1
daemon/exec/exec.go

@@ -53,7 +53,13 @@ func NewStore() *Store {
 
 
 // Commands returns the exec configurations in the store.
 // Commands returns the exec configurations in the store.
 func (e *Store) Commands() map[string]*Config {
 func (e *Store) Commands() map[string]*Config {
-	return e.commands
+	e.RLock()
+	commands := make(map[string]*Config, len(e.commands))
+	for id, config := range e.commands {
+		commands[id] = config
+	}
+	e.RUnlock()
+	return commands
 }
 }
 
 
 // Add adds a new exec configuration to the store.
 // Add adds a new exec configuration to the store.