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.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index cbeb5ea3d..a784e1262 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -2448,25 +2448,20 @@ static int register_service_noref(void *data)
return 0;
}
-static int register_service(void *data)
-{
- int res;
-
- if (!(res = register_service_noref(data))) {
- ast_module_ref(ast_module_info->self);
- }
-
- return res;
-}
-
int internal_sip_register_service(pjsip_module *module)
{
return ast_sip_push_task_synchronous(NULL, register_service_noref, &module);
}
-int ast_sip_register_service(pjsip_module *module)
+int __ast_sip_register_service(pjsip_module *module, const char *file, int line, const char *func)
{
- return ast_sip_push_task_synchronous(NULL, register_service, &module);
+ int res;
+
+ if (!(res = ast_sip_push_task_synchronous(NULL, register_service_noref, &module))) {
+ __ast_module_ref(ast_module_info->self, file, line, func);
+ }
+
+ return res;
}
static int unregister_service_noref(void *data)
@@ -2480,25 +2475,16 @@ static int unregister_service_noref(void *data)
return 0;
}
-static int unregister_service(void *data)
-{
- int res;
-
- if (!(res = unregister_service_noref(data))) {
- ast_module_unref(ast_module_info->self);
- }
-
- return res;
-}
-
int internal_sip_unregister_service(pjsip_module *module)
{
return ast_sip_push_task_synchronous(NULL, unregister_service_noref, &module);
}
-void ast_sip_unregister_service(pjsip_module *module)
+void __ast_sip_unregister_service(pjsip_module *module, const char *file, int line, const char *func)
{
- ast_sip_push_task_synchronous(NULL, unregister_service, &module);
+ if (!ast_sip_push_task_synchronous(NULL, unregister_service_noref, &module)) {
+ __ast_module_unref(ast_module_info->self, file, line, func);
+ }
}
static struct ast_sip_authenticator *registered_authenticator;
@@ -3542,7 +3528,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;
@@ -3560,22 +3546,41 @@ int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
if (!inserted) {
AST_RWLIST_INSERT_TAIL(&supplements, supplement, next);
}
- ast_module_ref(ast_module_info->self);
+}
+
+int __ast_sip_register_supplement(struct ast_sip_supplement *supplement,
+ const char *file, int line, const char *func)
+{
+ internal_sip_register_supplement(supplement);
+ __ast_module_ref(ast_module_info->self, file, line, func);
+
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,
+ const char *file, int line, const char *func)
+{
+ if (!internal_sip_unregister_supplement(supplement)) {
+ __ast_module_unref(ast_module_info->self, file, line, func);
+ }
}
static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)