Fix leaking tickers (#314)
This commit is contained in:
parent
d55c9a45e7
commit
b07d1c4621
2 changed files with 4 additions and 0 deletions
3
voice.go
3
voice.go
|
@ -479,6 +479,7 @@ func (v *VoiceConnection) wsHeartbeat(wsConn *websocket.Conn, close <-chan struc
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
ticker := time.NewTicker(i * time.Millisecond)
|
ticker := time.NewTicker(i * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
v.log(LogDebug, "sending heartbeat packet")
|
v.log(LogDebug, "sending heartbeat packet")
|
||||||
v.wsMutex.Lock()
|
v.wsMutex.Lock()
|
||||||
|
@ -629,6 +630,7 @@ func (v *VoiceConnection) udpKeepAlive(udpConn *net.UDPConn, close <-chan struct
|
||||||
packet := make([]byte, 8)
|
packet := make([]byte, 8)
|
||||||
|
|
||||||
ticker := time.NewTicker(i)
|
ticker := time.NewTicker(i)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
|
|
||||||
binary.LittleEndian.PutUint64(packet, sequence)
|
binary.LittleEndian.PutUint64(packet, sequence)
|
||||||
|
@ -684,6 +686,7 @@ func (v *VoiceConnection) opusSender(udpConn *net.UDPConn, close <-chan struct{}
|
||||||
|
|
||||||
// start a send loop that loops until buf chan is closed
|
// start a send loop that loops until buf chan is closed
|
||||||
ticker := time.NewTicker(time.Millisecond * time.Duration(size/(rate/1000)))
|
ticker := time.NewTicker(time.Millisecond * time.Duration(size/(rate/1000)))
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
|
|
||||||
// Get data from chan. If chan is closed, return.
|
// Get data from chan. If chan is closed, return.
|
||||||
|
|
1
wsapi.go
1
wsapi.go
|
@ -200,6 +200,7 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
ticker := time.NewTicker(i * time.Millisecond)
|
ticker := time.NewTicker(i * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
sequence := atomic.LoadInt64(s.sequence)
|
sequence := atomic.LoadInt64(s.sequence)
|
||||||
|
|
Loading…
Reference in a new issue