1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon/events: let Log be [slightly] blocking

With go1.5's concurrency, the use of a goroutine in Log'ing events was
causing the resulting events to not be in order.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
This commit is contained in:
Vincent Batts 2015-09-15 14:28:22 -04:00
parent 59311faaed
commit 09e7dd03f8

View file

@ -45,9 +45,8 @@ func (e *Events) Evict(l chan interface{}) {
// Log broadcasts event to listeners. Each listener has 100 millisecond for
// receiving event or it will be skipped.
func (e *Events) Log(action, id, from string) {
go func() {
e.mu.Lock()
jm := &jsonmessage.JSONMessage{Status: action, ID: id, From: from, Time: time.Now().UTC().Unix()}
e.mu.Lock()
if len(e.events) == cap(e.events) {
// discard oldest event
copy(e.events, e.events[1:])
@ -57,7 +56,6 @@ func (e *Events) Log(action, id, from string) {
}
e.mu.Unlock()
e.pub.Publish(jm)
}()
}
// SubscribersCount returns number of event listeners