summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
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)