[Asterisk-code-review] res pjsip: Add REF DEBUG info to module references. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Wed Oct 4 11:03:27 CDT 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/6648


Change subject: res_pjsip: Add REF_DEBUG info to module references.
......................................................................

res_pjsip: Add REF_DEBUG info to module references.

This provides better information to REF_DEBUG log for troubleshooting
when the system is unable to unload res_pjsip.so during shutdown due to
module references.

ASTERISK-27306

Change-Id: I63197ad33d1aebe60d12e0a6561718bdc54e4612
---
M include/asterisk/res_pjsip.h
M include/asterisk/res_pjsip_session.h
M res/res_pjsip.c
M res/res_pjsip.exports.in
M res/res_pjsip/pjsip_session.c
M res/res_pjsip_session.exports.in
6 files changed, 48 insertions(+), 40 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/48/6648/1

diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index b6403d6..e6ccf0a 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -925,7 +925,9 @@
  * \retval 0 Success
  * \retval -1 Failure
  */
-int ast_sip_register_service(pjsip_module *module);
+#define ast_sip_register_service(module) \
+	__ast_sip_register_service(module, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+int __ast_sip_register_service(pjsip_module *module, const char *file, int line, const char *func);
 
 /*!
  * This is the opposite of ast_sip_register_service().  Unregistering a
@@ -934,7 +936,9 @@
  *
  * \param module The PJSIP module to unregister
  */
-void ast_sip_unregister_service(pjsip_module *module);
+#define ast_sip_unregister_service(module) \
+	__ast_sip_unregister_service(module, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+void __ast_sip_unregister_service(pjsip_module *module, const char *file, int line, const char *func);
 
 /*!
  * \brief Register a SIP authenticator
@@ -2615,14 +2619,20 @@
  * \retval 0 Success
  * \retval -1 Failure
  */
-int ast_sip_register_supplement(struct ast_sip_supplement *supplement);
+#define ast_sip_register_supplement(supplement) \
+	__ast_sip_register_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+int __ast_sip_register_supplement(struct ast_sip_supplement *supplement,
+	const char *file, int line, const char *func);
 
 /*!
  * \brief Unregister a an supplement to SIP out of dialog processing
  *
  * \param supplement The supplement to unregister
  */
-void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement);
+#define ast_sip_unregister_supplement(supplement) \
+	__ast_sip_unregister_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+void __ast_sip_unregister_supplement(struct ast_sip_supplement *supplement,
+	const char *file, int line, const char *func);
 
 /*!
  * \brief Retrieve the global MWI taskprocessor high water alert trigger level.
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index 70f9468..b7a22b93 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -578,14 +578,20 @@
  * \retval 0 Success
  * \retval -1 Failure
  */
-int ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement);
+#define ast_sip_session_register_supplement(supplement) \
+	__ast_sip_session_register_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+int __ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement,
+	const char *file, int line, const char *func);
 
 /*!
  * \brief Unregister a an supplement to SIP session processing
  *
  * \param supplement The supplement to unregister
  */
-void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement);
+#define ast_sip_session_unregister_supplement(supplement) \
+	__ast_sip_session_unregister_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+void __ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement,
+	const char *file, int line, const char *func);
 
 /*!
  * \brief Add supplements to a SIP session
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index ac275bd..fb919b3 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -2422,25 +2422,20 @@
 	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)
@@ -2454,25 +2449,16 @@
 	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;
@@ -3536,10 +3522,11 @@
 	}
 }
 
-int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
+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);
+	__ast_module_ref(ast_module_info->self, file, line, func);
 
 	return 0;
 }
@@ -3562,10 +3549,11 @@
 	return res;
 }
 
-void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
+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);
+		__ast_module_unref(ast_module_info->self, file, line, func);
 	}
 }
 
diff --git a/res/res_pjsip.exports.in b/res/res_pjsip.exports.in
index 4adecd4..7ac2b7e 100644
--- a/res/res_pjsip.exports.in
+++ b/res/res_pjsip.exports.in
@@ -1,6 +1,7 @@
 {
 	global:
 		LINKER_SYMBOL_PREFIXast_sip_*;
+		LINKER_SYMBOL_PREFIX__ast_sip_*;
 		LINKER_SYMBOL_PREFIXast_copy_pj_str;
 		LINKER_SYMBOL_PREFIXast_copy_pj_str2;
 		LINKER_SYMBOL_PREFIXast_pjsip_rdata_get_endpoint;
diff --git a/res/res_pjsip/pjsip_session.c b/res/res_pjsip/pjsip_session.c
index cea7243..4f3e3be 100644
--- a/res/res_pjsip/pjsip_session.c
+++ b/res/res_pjsip/pjsip_session.c
@@ -56,10 +56,11 @@
 	}
 }
 
-int ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement)
+int __ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement,
+	const char *file, int line, const char *func)
 {
 	internal_sip_session_register_supplement(supplement);
-	ast_module_ref(AST_MODULE_SELF);
+	__ast_module_ref(AST_MODULE_SELF, file, line, func);
 
 	return 0;
 }
@@ -82,10 +83,11 @@
 	return res;
 }
 
-void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
+void __ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement,
+	const char *file, int line, const char *func)
 {
 	if (!internal_sip_session_unregister_supplement(supplement)) {
-		ast_module_unref(AST_MODULE_SELF);
+		__ast_module_unref(AST_MODULE_SELF, file, line, func);
 	}
 }
 
diff --git a/res/res_pjsip_session.exports.in b/res/res_pjsip_session.exports.in
index b7bd21b8..d65b247 100644
--- a/res/res_pjsip_session.exports.in
+++ b/res/res_pjsip_session.exports.in
@@ -1,6 +1,7 @@
 {
 	global:
 		LINKER_SYMBOL_PREFIXast_sip_session_*;
+		LINKER_SYMBOL_PREFIX__ast_sip_session_*;
 		LINKER_SYMBOL_PREFIXast_sip_dialog_get_session;
 		LINKER_SYMBOL_PREFIXast_sip_channel_pvt_alloc;
 	local:

-- 
To view, visit https://gerrit.asterisk.org/6648
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63197ad33d1aebe60d12e0a6561718bdc54e4612
Gerrit-Change-Number: 6648
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171004/3c1faa1a/attachment.html>


More information about the asterisk-code-review mailing list