Fix race in LogEvent

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
Upstream-commit: a1b7a35c90f05b113b7c3aa474b74d1d2afbf7b6
Component: engine
This commit is contained in:
Alexandr Morozov
2014-06-11 15:23:33 +04:00
parent 5c1bb534bb
commit f9497861c8
+2
View File
@@ -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
}