Changed the order of the heartbeat lock to be a little better.
This commit is contained in:
parent
825144012d
commit
ed1076361e
1 changed files with 3 additions and 2 deletions
5
wsapi.go
5
wsapi.go
|
@ -427,10 +427,11 @@ func (s *Session) Heartbeat(i time.Duration) {
|
||||||
s.heartbeatLock.Unlock()
|
s.heartbeatLock.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.heartbeatRunning = true
|
|
||||||
defer func() { s.heartbeatRunning = false }()
|
|
||||||
s.heartbeatLock.Unlock()
|
s.heartbeatLock.Unlock()
|
||||||
|
|
||||||
|
defer func() { s.heartbeatRunning = false }()
|
||||||
|
s.heartbeatRunning = true
|
||||||
|
|
||||||
// send first heartbeat immediately because lag could put the
|
// send first heartbeat immediately because lag could put the
|
||||||
// first heartbeat outside the required heartbeat interval window
|
// first heartbeat outside the required heartbeat interval window
|
||||||
ticker := time.NewTicker(i * time.Millisecond)
|
ticker := time.NewTicker(i * time.Millisecond)
|
||||||
|
|
Loading…
Reference in a new issue