1
0
Fork 0
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:
Alexandr Morozov 2014-06-05 13:35:24 +04:00
parent fa7c8d523e
commit a1b7a35c90

View file

@ -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
} }