Skip to content

Commit e8b746b

Browse files
authored
rtsp: fix memory leak when closing sessions (#4964) (#4678) (#4967)
1 parent 0c80156 commit e8b746b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/servers/rtsp/session.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ func (s *session) initialize() {
102102
}
103103

104104
// Close closes a Session.
105+
// this is not always called, so things that need to be released
106+
// must go in onClose().
105107
func (s *session) Close() {
106-
s.discardedFrames.Stop()
107-
s.decodeErrors.Stop()
108-
s.packetsLost.Stop()
109108
s.rsession.Close()
110109
}
111110

@@ -136,6 +135,10 @@ func (s *session) onClose(err error) {
136135
s.path = nil
137136
s.stream = nil
138137

138+
s.discardedFrames.Stop()
139+
s.decodeErrors.Stop()
140+
s.packetsLost.Stop()
141+
139142
s.Log(logger.Info, "destroyed: %v", err)
140143
}
141144

0 commit comments

Comments
 (0)