mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Avoid leaking tickers
In Go 1.22 and earlier, a ticker needs to be explicitly stopped when it's no longer useful in order to avoid a resource leak. In Go 1.23 and later, an orphaned ticker will eventually be garbage collected, but it's still more thrifty to stop it early.
This commit is contained in:

committed by
Sean DuBois

parent
cbbb1c29e5
commit
f29ef99b22
@@ -92,6 +92,7 @@ func TestPeerConnection_Interceptor(t *testing.T) {
|
||||
|
||||
func() {
|
||||
ticker := time.NewTicker(time.Millisecond * 20)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-seenRTP.Done():
|
||||
@@ -252,7 +253,9 @@ func Test_Interceptor_ZeroSSRC(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
sequenceNumber := uint16(0)
|
||||
for range time.NewTicker(time.Millisecond * 20).C {
|
||||
ticker := time.NewTicker(time.Millisecond * 20)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
track.mu.Lock()
|
||||
if len(track.bindings) == 1 {
|
||||
_, err = track.bindings[0].writeStream.WriteRTP(&rtp.Header{
|
||||
|
Reference in New Issue
Block a user