Browse code

Fix race condition in sending started signal from monitor

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>

Alexandr Morozov authored on 2014/08/14 16:01:39
Showing 1 changed files
... ...
@@ -244,10 +244,12 @@ func (m *containerMonitor) callback(command *execdriver.Command) {
244 244
 
245 245
 	m.container.State.SetRunning(command.Pid())
246 246
 
247
-	if m.startSignal != nil {
248
-		// signal that the process has started
247
+	// signal that the process has started
248
+	// close channel only if not closed
249
+	select {
250
+	case <-m.startSignal:
251
+	default:
249 252
 		close(m.startSignal)
250
-		m.startSignal = nil
251 253
 	}
252 254
 
253 255
 	if err := m.container.ToDisk(); err != nil {