Просмотр исходного кода

Merge remote-tracking branch 'origin/wait_non_existing_container-fix'

Solomon Hykes 12 лет назад
Родитель
Сommit
76b7b2adf7
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      runtime.go

+ 11 - 0
runtime.go

@@ -134,6 +134,9 @@ func (runtime *Runtime) Register(container *Container) error {
 		return err
 		return err
 	}
 	}
 
 
+	// init the wait lock
+	container.waitLock = make(chan struct{})
+
 	// FIXME: if the container is supposed to be running but is not, auto restart it?
 	// FIXME: if the container is supposed to be running but is not, auto restart it?
 	//        if so, then we need to restart monitor and init a new lock
 	//        if so, then we need to restart monitor and init a new lock
 	// If the container is supposed to be running, make sure of it
 	// If the container is supposed to be running, make sure of it
@@ -150,6 +153,14 @@ func (runtime *Runtime) Register(container *Container) error {
 			}
 			}
 		}
 		}
 	}
 	}
+
+	// If the container is not running or just has been flagged not running
+	// then close the wait lock chan (will be reset upon start)
+	if !container.State.Running {
+		close(container.waitLock)
+	}
+
+	// Even if not running, we init the lock (prevents races in start/stop/kill)
 	container.State.initLock()
 	container.State.initLock()
 
 
 	container.runtime = runtime
 	container.runtime = runtime