From a1b7a35c90f05b113b7c3aa474b74d1d2afbf7b6 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 5 Jun 2014 13:35:24 +0400 Subject: [PATCH] Fix race in LogEvent Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) --- server/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/server.go b/server/server.go index af62db879d..76a51e796f 100644 --- a/server/server.go +++ b/server/server.go @@ -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 }