res_pjsip: Patch for res_pjsip_* module load/reload crash

The session_supplements for the pjsip makes crashes when the module
load/unload.

ASTERISK-28157

Change-Id: I5b82be3a75d702cf1933d8d1417f44aa10ad1029
This commit is contained in:
Corey Farrell
2018-11-27 11:20:59 -05:00
parent 9f0459d2a0
commit ec02d7fd4c
2 changed files with 15 additions and 2 deletions

View File

@@ -533,10 +533,14 @@ void ast_sip_session_unregister_sdp_handler(struct ast_sip_session_sdp_handler *
* a module could reject an incoming request if desired. * a module could reject an incoming request if desired.
* *
* \param supplement The supplement to register * \param supplement The supplement to register
* \param module Referenced module(NULL safe)
* \retval 0 Success * \retval 0 Success
* \retval -1 Failure * \retval -1 Failure
*/ */
int ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement); int ast_sip_session_register_supplement_with_module(struct ast_module *module, struct ast_sip_session_supplement *supplement);
#define ast_sip_session_register_supplement(supplement) \
ast_sip_session_register_supplement_with_module(ast_module_info->self, supplement)
/*! /*!
* \brief Unregister a an supplement to SIP session processing * \brief Unregister a an supplement to SIP session processing

View File

@@ -56,10 +56,11 @@ void internal_sip_session_register_supplement(struct ast_sip_session_supplement
} }
} }
int ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement) int ast_sip_session_register_supplement_with_module(struct ast_module *module, struct ast_sip_session_supplement *supplement)
{ {
internal_sip_session_register_supplement(supplement); internal_sip_session_register_supplement(supplement);
internal_res_pjsip_ref(); internal_res_pjsip_ref();
ast_module_shutdown_ref(module);
return 0; return 0;
} }
@@ -118,3 +119,11 @@ int ast_sip_session_add_supplements(struct ast_sip_session *session)
return 0; return 0;
} }
/* This stub is for ABI compatibility. */
#undef ast_sip_session_register_supplement
int ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement);
int ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement)
{
return ast_sip_session_register_supplement_with_module(NULL, supplement);
}