From 5c1bb534bb171f09ca9e43f0a97de834c4e019f4 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 5 Jun 2014 11:17:09 +0400 Subject: [PATCH] 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) {