summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2017-10-09 17:51:12 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-10-09 17:51:12 -0500
commit1c3345ac3febb8374f3616091dc6bc7f429a6ff3 (patch)
treee777802cb6e427423f6106fc1b2d69330b73de6d /res/res_pjsip.c
parent521c73955b9da5a0b8f459b856a1d4eb3b063701 (diff)
parentcf474bf57af6811c343700f896bc6def41960266 (diff)
Merge "res_pjsip: Fix issues that prevented shutdown of modules." into 14
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 4d5c5cb83..844d8a1cc 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3476,7 +3476,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;
@@ -3494,22 +3494,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)