]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Add REF_DEBUG info to module references.
authorCorey Farrell <git@cfware.com>
Wed, 4 Oct 2017 15:59:49 +0000 (11:59 -0400)
committerCorey Farrell <git@cfware.com>
Wed, 4 Oct 2017 16:00:47 +0000 (12:00 -0400)
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

include/asterisk/res_pjsip.h
include/asterisk/res_pjsip_session.h
res/res_pjsip.c
res/res_pjsip.exports.in
res/res_pjsip/pjsip_session.c
res/res_pjsip_session.exports.in

index b6403d6fadc7edaa61d1c0c89beca2d0af6c8ee9..e6ccf0a1d4f0de0a8a23640f7bf22f6face94708 100644 (file)
@@ -925,7 +925,9 @@ enum ast_sip_contact_filter {
  * \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 @@ int ast_sip_register_service(pjsip_module *module);
  *
  * \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 @@ struct ast_sip_supplement {
  * \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.
index 70f94682e0ee709a9fe34592892ce4fef3cfe297..b7a22b93790af6d71cad9fc5e2c999606f3016c6 100644 (file)
@@ -578,14 +578,20 @@ void ast_sip_session_unregister_sdp_handler(struct ast_sip_session_sdp_handler *
  * \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
index ac275bd08413b91bc3e9d1cb5bff11535236ec82..fb919b32b2b37b4c28287376ec200bfb134fe112 100644 (file)
@@ -2422,25 +2422,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)
@@ -2454,25 +2449,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;
@@ -3536,10 +3522,11 @@ void internal_sip_register_supplement(struct ast_sip_supplement *supplement)
        }
 }
 
-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 @@ int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement)
        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);
        }
 }
 
index 4adecd419c225ead7709d147fd25f3eb70186e3e..7ac2b7e83aaf7095d348879719f134e0fdf10bce 100644 (file)
@@ -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;
index cea72436ab5c8f9693e4952470f4172385bd5830..4f3e3be5566c38f6bc82715a3918f0da2ab8193a 100644 (file)
@@ -56,10 +56,11 @@ void internal_sip_session_register_supplement(struct ast_sip_session_supplement
        }
 }
 
-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 @@ int internal_sip_session_unregister_supplement(struct ast_sip_session_supplement
        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);
        }
 }
 
index b7bd21b893df630ab682906bc23df8cd88e14b9c..d65b247c7a1248a5757c518d3d23fc70993c0f64 100644 (file)
@@ -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: