mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix race in LogEvent
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
parent
fa7c8d523e
commit
a1b7a35c90
1 changed files with 2 additions and 0 deletions
|
@ -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…
Reference in a new issue