server: correctly close sessions in case of errors during SETUP

(https://github.com/aler9/rtsp-simple-server/issues/965)
This commit is contained in:
aler9
2022-06-21 14:54:07 +02:00
parent c6b5540702
commit f4cc42eccc
2 changed files with 67 additions and 55 deletions

View File

@@ -337,7 +337,8 @@ func (ss *ServerSession) runInner() error {
res, err := ss.handleRequest(req.sc, req.req)
var returnedSession *ServerSession
returnedSession := ss
if err == nil || err == errSwitchReadFunc {
// ANNOUNCE responses don't contain the session header.
if req.req.Method != base.Announce &&
@@ -364,9 +365,9 @@ func (ss *ServerSession) runInner() error {
}.Write()
}
// after a TEARDOWN, session must be unpaired with the connection.
if req.req.Method != base.Teardown {
returnedSession = ss
// after a TEARDOWN, session must be unpaired with the connection
if req.req.Method == base.Teardown {
returnedSession = nil
}
}