fix memory leak when reloading the configuration (#4855)

When a path has a MPEG-TS, RTP or WebRTC source and the path
configuration is reloaded, a routine was left open because the reload
channel was not handled. This fixes the issue.
This commit is contained in:
Alessandro Ros 2025-08-11 17:50:40 +02:00 committed by GitHub
parent 6d4dfff959
commit 61382e496b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 158 additions and 93 deletions

View file

@ -80,15 +80,19 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error {
readerErr <- s.runReader(&desc, nc)
}()
select {
case err = <-readerErr:
nc.Close()
return err
for {
select {
case err = <-readerErr:
nc.Close()
return err
case <-params.Context.Done():
nc.Close()
<-readerErr
return fmt.Errorf("terminated")
case <-params.ReloadConf:
case <-params.Context.Done():
nc.Close()
<-readerErr
return fmt.Errorf("terminated")
}
}
}