mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #6214 from LK4D4/fix_some_more_race_conditions
Fix some more race conditions
This commit is contained in:
commit
51b188c510
3 changed files with 10 additions and 1 deletions
|
@ -808,11 +808,16 @@ func (container *Container) GetPtyMaster() (*os.File, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) HostConfig() *runconfig.HostConfig {
|
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) {
|
func (container *Container) SetHostConfig(hostConfig *runconfig.HostConfig) {
|
||||||
|
container.Lock()
|
||||||
container.hostConfig = hostConfig
|
container.hostConfig = hostConfig
|
||||||
|
container.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) DisableLink(name string) {
|
func (container *Container) DisableLink(name string) {
|
||||||
|
|
|
@ -72,9 +72,11 @@ func (c *contStore) Delete(id string) {
|
||||||
|
|
||||||
func (c *contStore) List() []*Container {
|
func (c *contStore) List() []*Container {
|
||||||
containers := new(History)
|
containers := new(History)
|
||||||
|
c.Lock()
|
||||||
for _, cont := range c.s {
|
for _, cont := range c.s {
|
||||||
containers.Add(cont)
|
containers.Add(cont)
|
||||||
}
|
}
|
||||||
|
c.Unlock()
|
||||||
containers.Sort()
|
containers.Sort()
|
||||||
return *containers
|
return *containers
|
||||||
}
|
}
|
||||||
|
|
|
@ -2402,12 +2402,14 @@ func (srv *Server) LogEvent(action, id, from string) *utils.JSONMessage {
|
||||||
now := time.Now().UTC().Unix()
|
now := time.Now().UTC().Unix()
|
||||||
jm := utils.JSONMessage{Status: action, ID: id, From: from, Time: now}
|
jm := utils.JSONMessage{Status: action, ID: id, From: from, Time: now}
|
||||||
srv.AddEvent(jm)
|
srv.AddEvent(jm)
|
||||||
|
srv.Lock()
|
||||||
for _, c := range srv.listeners {
|
for _, c := range srv.listeners {
|
||||||
select { // non blocking channel
|
select { // non blocking channel
|
||||||
case c <- jm:
|
case c <- jm:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
srv.Unlock()
|
||||||
return &jm
|
return &jm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue