forked from pothtonswer/discordmuffin
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()
|
s.wsMutex.Unlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(LogError, "error sending heartbeat to gateway %s, %s", s.gateway, err)
|
s.log(LogError, "error sending heartbeat to gateway %s, %s", s.gateway, err)
|
||||||
|
s.Lock()
|
||||||
s.DataReady = false
|
s.DataReady = false
|
||||||
|
s.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
s.Lock()
|
||||||
s.DataReady = true
|
s.DataReady = true
|
||||||
|
s.Unlock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
Loading…
Reference in a new issue