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
1 changed files with 2 additions and 0 deletions

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
}