Skip to content

Commit

Permalink
fix memory leak in case of errors during initialization of a reader
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Oct 4, 2024
1 parent ccde336 commit a277689
Show file tree
Hide file tree
Showing 37 changed files with 1,596 additions and 1,430 deletions.
76 changes: 0 additions & 76 deletions internal/asyncwriter/async_writer.go

This file was deleted.

22 changes: 0 additions & 22 deletions internal/asyncwriter/async_writer_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions internal/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ func (p *Core) createResources(initial bool) error {
Address: p.conf.RTMPAddress,
ReadTimeout: p.conf.ReadTimeout,
WriteTimeout: p.conf.WriteTimeout,
WriteQueueSize: p.conf.WriteQueueSize,
IsTLS: false,
ServerCert: "",
ServerKey: "",
Expand Down Expand Up @@ -471,7 +470,6 @@ func (p *Core) createResources(initial bool) error {
Address: p.conf.RTMPSAddress,
ReadTimeout: p.conf.ReadTimeout,
WriteTimeout: p.conf.WriteTimeout,
WriteQueueSize: p.conf.WriteQueueSize,
IsTLS: true,
ServerCert: p.conf.RTMPServerCert,
ServerKey: p.conf.RTMPServerKey,
Expand Down Expand Up @@ -511,7 +509,6 @@ func (p *Core) createResources(initial bool) error {
SegmentMaxSize: p.conf.HLSSegmentMaxSize,
Directory: p.conf.HLSDirectory,
ReadTimeout: p.conf.ReadTimeout,
WriteQueueSize: p.conf.WriteQueueSize,
MuxerCloseAfter: p.conf.HLSMuxerCloseAfter,
PathManager: p.pathManager,
Parent: p,
Expand Down Expand Up @@ -539,7 +536,6 @@ func (p *Core) createResources(initial bool) error {
AllowOrigin: p.conf.WebRTCAllowOrigin,
TrustedProxies: p.conf.WebRTCTrustedProxies,
ReadTimeout: p.conf.ReadTimeout,
WriteQueueSize: p.conf.WriteQueueSize,
LocalUDPAddress: p.conf.WebRTCLocalUDPAddress,
LocalTCPAddress: p.conf.WebRTCLocalTCPAddress,
IPsFromInterfaces: p.conf.WebRTCIPsFromInterfaces,
Expand Down Expand Up @@ -570,7 +566,6 @@ func (p *Core) createResources(initial bool) error {
RTSPAddress: p.conf.RTSPAddress,
ReadTimeout: p.conf.ReadTimeout,
WriteTimeout: p.conf.WriteTimeout,
WriteQueueSize: p.conf.WriteQueueSize,
UDPMaxPayloadSize: p.conf.UDPMaxPayloadSize,
RunOnConnect: p.conf.RunOnConnect,
RunOnConnectRestart: p.conf.RunOnConnectRestart,
Expand Down Expand Up @@ -755,7 +750,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
newConf.RTMPAddress != p.conf.RTMPAddress ||
newConf.ReadTimeout != p.conf.ReadTimeout ||
newConf.WriteTimeout != p.conf.WriteTimeout ||
newConf.WriteQueueSize != p.conf.WriteQueueSize ||
newConf.RTSPAddress != p.conf.RTSPAddress ||
newConf.RunOnConnect != p.conf.RunOnConnect ||
newConf.RunOnConnectRestart != p.conf.RunOnConnectRestart ||
Expand All @@ -770,7 +764,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
newConf.RTMPSAddress != p.conf.RTMPSAddress ||
newConf.ReadTimeout != p.conf.ReadTimeout ||
newConf.WriteTimeout != p.conf.WriteTimeout ||
newConf.WriteQueueSize != p.conf.WriteQueueSize ||
newConf.RTMPServerCert != p.conf.RTMPServerCert ||
newConf.RTMPServerKey != p.conf.RTMPServerKey ||
newConf.RTSPAddress != p.conf.RTSPAddress ||
Expand All @@ -797,7 +790,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
newConf.HLSSegmentMaxSize != p.conf.HLSSegmentMaxSize ||
newConf.HLSDirectory != p.conf.HLSDirectory ||
newConf.ReadTimeout != p.conf.ReadTimeout ||
newConf.WriteQueueSize != p.conf.WriteQueueSize ||
newConf.HLSMuxerCloseAfter != p.conf.HLSMuxerCloseAfter ||
closePathManager ||
closeMetrics ||
Expand All @@ -812,7 +804,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
newConf.WebRTCAllowOrigin != p.conf.WebRTCAllowOrigin ||
!reflect.DeepEqual(newConf.WebRTCTrustedProxies, p.conf.WebRTCTrustedProxies) ||
newConf.ReadTimeout != p.conf.ReadTimeout ||
newConf.WriteQueueSize != p.conf.WriteQueueSize ||
newConf.WebRTCLocalUDPAddress != p.conf.WebRTCLocalUDPAddress ||
newConf.WebRTCLocalTCPAddress != p.conf.WebRTCLocalTCPAddress ||
newConf.WebRTCIPsFromInterfaces != p.conf.WebRTCIPsFromInterfaces ||
Expand All @@ -831,7 +822,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
newConf.RTSPAddress != p.conf.RTSPAddress ||
newConf.ReadTimeout != p.conf.ReadTimeout ||
newConf.WriteTimeout != p.conf.WriteTimeout ||
newConf.WriteQueueSize != p.conf.WriteQueueSize ||
newConf.UDPMaxPayloadSize != p.conf.UDPMaxPayloadSize ||
newConf.RunOnConnect != p.conf.RunOnConnect ||
newConf.RunOnConnectRestart != p.conf.RunOnConnectRestart ||
Expand Down
2 changes: 1 addition & 1 deletion internal/core/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ func (pa *path) onDemandPublisherStop(reason string) {
func (pa *path) setReady(desc *description.Session, allocateEncoder bool) error {
var err error
pa.stream, err = stream.New(
pa.writeQueueSize,
pa.udpMaxPayloadSize,
desc,
allocateEncoder,
Expand Down Expand Up @@ -777,7 +778,6 @@ func (pa *path) setNotReady() {

func (pa *path) startRecording() {
pa.recorder = &recorder.Recorder{
WriteQueueSize: pa.writeQueueSize,
PathFormat: pa.conf.RecordPath,
Format: pa.conf.RecordFormat,
PartDuration: time.Duration(pa.conf.RecordPartDuration),
Expand Down
Loading

0 comments on commit a277689

Please sign in to comment.