From 69f00a137c886bd0e06b9fd2bb438f4eab1ade50 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Mon, 19 Sep 2016 07:42:21 +0000 Subject: [PATCH] Fix a race in libcontainerd/pausemonitor_linux.go Signed-off-by: Akihiro Suda --- libcontainerd/pausemonitor_linux.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libcontainerd/pausemonitor_linux.go b/libcontainerd/pausemonitor_linux.go index 379cbf1fcb..80f5d025db 100644 --- a/libcontainerd/pausemonitor_linux.go +++ b/libcontainerd/pausemonitor_linux.go @@ -1,11 +1,18 @@ package libcontainerd +import ( + "sync" +) + // pauseMonitor is helper to get notifications from pause state changes. type pauseMonitor struct { + sync.Mutex waiters map[string][]chan struct{} } func (m *pauseMonitor) handle(t string) { + m.Lock() + defer m.Unlock() if m.waiters == nil { return } @@ -20,6 +27,8 @@ func (m *pauseMonitor) handle(t string) { } func (m *pauseMonitor) append(t string, waiter chan struct{}) { + m.Lock() + defer m.Unlock() if m.waiters == nil { m.waiters = make(map[string][]chan struct{}) }