From d6b2a58736a6c831f11a8d28a2a1d74d83bd74cb Mon Sep 17 00:00:00 2001 From: George Joseph Date: Thu, 27 Apr 2017 07:02:12 -0600 Subject: res_pjsip_session: Add cleanup to ast_sip_session_terminate If you use ast_request to create a PJSIP channel but then hang it up without causing a transaction to be sent, the session will never be destroyed. This is due ot the fact that it's pjproject that triggers the session cleanup when the transaction ends. app_chanisavail was doing this to get more granular channel state and it's also possible for this to happen via ARI. * ast_sip_session_terminate was modified to explicitly call the cleanup tasks and unreference session if the invite state is NULL AND invite_tsx is NULL (meaning we never sent a transaction). * chan_pjsip/hangup was modified to bump session before it calls ast_sip_session_terminate to insure that session stays valid while it does its own cleanup. * Added test events to session_destructor for a future testsuite test. ASTERISK-26908 #close Reported-by: Richard Mudgett Change-Id: I52daf6f757184e5544c261f64f6fe9602c4680a9 --- include/asterisk/res_pjsip_session.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/asterisk/res_pjsip_session.h') diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h index d4d3f705a..10e55f133 100644 --- a/include/asterisk/res_pjsip_session.h +++ b/include/asterisk/res_pjsip_session.h @@ -459,6 +459,10 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint * * \param session The session to terminate * \param response The response code to use for termination if possible + * + * \warning Calling this function MAY cause the last session reference to be + * released and the session destructor to be called. If you need to do something + * with session after this call, be sure to bump the ref count before calling terminate. */ void ast_sip_session_terminate(struct ast_sip_session *session, int response); -- cgit v1.2.3