From ca798d0a38ffc60fd57a34d88113501e478ce231 Mon Sep 17 00:00:00 2001 From: Francisco Souza Date: Tue, 26 Apr 2016 18:45:57 -0300 Subject: [PATCH] event: another dirty fix for another data race Related to #511. --- event.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/event.go b/event.go index 60eb0338..120cdc9b 100644 --- a/event.go +++ b/event.go @@ -317,10 +317,12 @@ func (c *Client) eventHijack(startTime int64, eventChan chan *APIEvents, errChan var event APIEvents if err = decoder.Decode(&event); err != nil { if err == io.EOF || err == io.ErrUnexpectedEOF { - if c.eventMonitor.isEnabled() && c.eventMonitor.C == eventChan { + c.eventMonitor.RLock() + if c.eventMonitor.enabled && c.eventMonitor.C == eventChan { // Signal that we're exiting. eventChan <- EOFEvent } + c.eventMonitor.RUnlock() break } errChan <- err