From 1480168e9f6178e4015aa4dcc035a6963c59f431 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 14 Aug 2014 11:01:39 +0400 Subject: [PATCH] Fix race condition in sending started signal from monitor Signed-off-by: Alexandr Morozov --- daemon/monitor.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon/monitor.go b/daemon/monitor.go index f0fb3d384e..e0fdece14e 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -244,10 +244,12 @@ func (m *containerMonitor) callback(command *execdriver.Command) { m.container.State.SetRunning(command.Pid()) - if m.startSignal != nil { - // signal that the process has started + // signal that the process has started + // close channel only if not closed + select { + case <-m.startSignal: + default: close(m.startSignal) - m.startSignal = nil } if err := m.container.ToDisk(); err != nil {