From ab194686ba62cef39b69b35f6769228ef93289b5 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 5 Jun 2014 10:49:40 +0400 Subject: [PATCH 1/3] Fix race in contStore.List Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) Upstream-commit: 0b3fe5544266b6f9657ecd87989b85b535cc63e1 Component: engine --- components/engine/daemon/daemon.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go index 7aa308782f..a766c8991b 100644 --- a/components/engine/daemon/daemon.go +++ b/components/engine/daemon/daemon.go @@ -72,9 +72,11 @@ func (c *contStore) Delete(id string) { func (c *contStore) List() []*Container { containers := new(History) + c.Lock() for _, cont := range c.s { containers.Add(cont) } + c.Unlock() containers.Sort() return *containers } From 5c1bb534bb171f09ca9e43f0a97de834c4e019f4 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 5 Jun 2014 11:17:09 +0400 Subject: [PATCH 2/3] Fix race in get/set HostConfig Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) Upstream-commit: fa7c8d523e8d899ade547fcaacc34a739ab5044f Component: engine --- components/engine/daemon/container.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/engine/daemon/container.go b/components/engine/daemon/container.go index 7eac1a75e3..dfe81c2c68 100644 --- a/components/engine/daemon/container.go +++ b/components/engine/daemon/container.go @@ -808,11 +808,16 @@ func (container *Container) GetPtyMaster() (*os.File, error) { } func (container *Container) HostConfig() *runconfig.HostConfig { - return container.hostConfig + container.Lock() + res := container.hostConfig + container.Unlock() + return res } func (container *Container) SetHostConfig(hostConfig *runconfig.HostConfig) { + container.Lock() container.hostConfig = hostConfig + container.Unlock() } func (container *Container) DisableLink(name string) { From f9497861c8c7ebe1363a02646eb7143d6caaa1c8 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 5 Jun 2014 13:35:24 +0400 Subject: [PATCH 3/3] Fix race in LogEvent Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) Upstream-commit: a1b7a35c90f05b113b7c3aa474b74d1d2afbf7b6 Component: engine --- components/engine/server/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/engine/server/server.go b/components/engine/server/server.go index af62db879d..76a51e796f 100644 --- a/components/engine/server/server.go +++ b/components/engine/server/server.go @@ -2402,12 +2402,14 @@ func (srv *Server) LogEvent(action, id, from string) *utils.JSONMessage { now := time.Now().UTC().Unix() jm := utils.JSONMessage{Status: action, ID: id, From: from, Time: now} srv.AddEvent(jm) + srv.Lock() for _, c := range srv.listeners { select { // non blocking channel case c <- jm: default: } } + srv.Unlock() return &jm }