Explorar o código

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

Bruce Marriner %!s(int64=9) %!d(string=hai) anos
pai
achega
ed1076361e
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      wsapi.go

+ 3 - 2
wsapi.go

@@ -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)