]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_session: Release media resources on session end quicker.
authorJoshua Colp <jcolp@digium.com>
Sat, 5 Aug 2017 11:36:49 +0000 (11:36 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 8 Aug 2017 00:53:24 +0000 (00:53 +0000)
A change was made long ago where the session was kept around
until the underlying INVITE session had been destroyed. This
had the side effect of also keeping the underlying media resources
around for this time as well.

This change ensures that when we are told to terminate the
session we immediately release any media sessions associated
with it.

ASTERISK-27110

Change-Id: I643e431d5c3bf05cda220c1d39e824a505a29b82

res/res_pjsip_session.c

index bb349a4b67d18f658748ee9f9b74dcc52fcdb1eb..31e20142d1f6819dec1ddcfc84e625394e8a64b2 100644 (file)
@@ -2396,6 +2396,15 @@ void ast_sip_session_terminate(struct ast_sip_session *session, int response)
                response = 603;
        }
 
+       /* The media sessions need to exist for the lifetime of the underlying channel
+        * to ensure that anything (such as bridge_native_rtp) has access to them as
+        * appropriate. Since ast_sip_session_terminate is called by chan_pjsip and other
+        * places when the session is to be terminated we terminate any existing
+        * media sessions here.
+        */
+       SWAP(session->active_media_state, session->pending_media_state);
+       ast_sip_session_media_state_reset(session->pending_media_state);
+
        switch (session->inv_session->state) {
        case PJSIP_INV_STATE_NULL:
                if (!session->inv_session->invite_tsx) {