summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-10-04 11:46:44 -0400
committerCorey Farrell <git@cfware.com>2017-10-04 12:00:31 -0400
commit7d04544986980aed9eca9e13d6b849ff3b372f35 (patch)
tree1650a39505f7760712b1fe7392827f0c80bd84d0 /res/res_pjsip.c
parent7156477ba023f5a5a5b4a64c50b407eb220200de (diff)
res_pjsip: Fix issues that prevented shutdown of modules.
res_pjsip and res_pjsip_session had circular references, preventing both modules from shutting down. * Move session supplement registration to res_pjsip. * Use create internal functions for use by pjsip_message_filter.c. ASTERISK-27306 Change-Id: Ifbd5c19ec848010111afeab2436f9699da06ba6b
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r--res/res_pjsip.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 6c1f77659..ac275bd08 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3516,7 +3516,7 @@ int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
AST_RWLIST_HEAD_STATIC(supplements, ast_sip_supplement);
-int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
+void internal_sip_register_supplement(struct ast_sip_supplement *supplement)
{
struct ast_sip_supplement *iter;
int inserted = 0;
@@ -3534,22 +3534,39 @@ int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
if (!inserted) {
AST_RWLIST_INSERT_TAIL(&supplements, supplement, next);
}
+}
+
+int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
+{
+ internal_sip_register_supplement(supplement);
ast_module_ref(ast_module_info->self);
+
return 0;
}
-void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
+int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement)
{
struct ast_sip_supplement *iter;
SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
+ int res = -1;
+
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {
if (supplement == iter) {
AST_RWLIST_REMOVE_CURRENT(next);
- ast_module_unref(ast_module_info->self);
+ res = 0;
break;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
+
+ return res;
+}
+
+void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
+{
+ if (!internal_sip_unregister_supplement(supplement)) {
+ ast_module_unref(ast_module_info->self);
+ }
}
static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)