Changed the order of the heartbeat lock to be a little better.

This commit is contained in:
Bruce Marriner 2016-01-02 22:34:54 -06:00
parent 825144012d
commit ed1076361e

View file

@ -427,10 +427,11 @@ func (s *Session) Heartbeat(i time.Duration) {
s.heartbeatLock.Unlock()
return
}
s.heartbeatRunning = true
defer func() { s.heartbeatRunning = false }()
s.heartbeatLock.Unlock()
defer func() { s.heartbeatRunning = false }()
s.heartbeatRunning = true
// send first heartbeat immediately because lag could put the
// first heartbeat outside the required heartbeat interval window
ticker := time.NewTicker(i * time.Millisecond)