Protect writes to DataReady with mutex lock
This commit is contained in:
parent
6c4d9f0ad7
commit
11f11de41c
1 changed files with 4 additions and 0 deletions
4
wsapi.go
4
wsapi.go
|
@ -194,10 +194,14 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}
|
|||
s.wsMutex.Unlock()
|
||||
if err != nil {
|
||||
s.log(LogError, "error sending heartbeat to gateway %s, %s", s.gateway, err)
|
||||
s.Lock()
|
||||
s.DataReady = false
|
||||
s.Unlock()
|
||||
return
|
||||
}
|
||||
s.Lock()
|
||||
s.DataReady = true
|
||||
s.Unlock()
|
||||
|
||||
select {
|
||||
case <-ticker.C:
|
||||
|
|
Loading…
Reference in a new issue