]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Fix crash when reloading certain configurations.
authorJoshua Colp <jcolp@digium.com>
Wed, 27 Nov 2013 16:12:56 +0000 (16:12 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 27 Nov 2013 16:12:56 +0000 (16:12 +0000)
Certain options available that specify a SIP URI perform validation
on the provided URI using the PJSIP URI parser. This operation
requires that the thread executing it be registered with the PJLIB
library. During reloads this was done on a thread which was NOT
registered with it.

This fixes the problem by creating a task which reloads the
configuration on a PJSIP thread.

(closes issue ASTERISK-22923)
Reported by: Anthony Messina
........

Merged revisions 403179 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403180 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_pjsip/pjsip_configuration.c

index 364ed7e19bd1b55c5b470ef0f4621c940a211d8d..4642c5e665ece0051523b50fd2b79bbae86e0516 100644 (file)
@@ -1404,7 +1404,11 @@ void ast_res_pjsip_destroy_configuration(void)
        ast_sorcery_unref(sip_sorcery);
 }
 
-int ast_res_pjsip_reload_configuration(void)
+/*!
+ * \internal
+ * \brief Reload configuration within a PJSIP thread
+ */
+static int reload_configuration_task(void *obj)
 {
        if (sip_sorcery) {
                ast_sorcery_reload(sip_sorcery);
@@ -1412,6 +1416,15 @@ int ast_res_pjsip_reload_configuration(void)
        return 0;
 }
 
+int ast_res_pjsip_reload_configuration(void)
+{
+       if (ast_sip_push_task(NULL, reload_configuration_task, NULL)) {
+               ast_log(LOG_WARNING, "Failed to reload PJSIP configuration\n");
+       }
+
+       return 0;
+}
+
 static void subscription_configuration_destroy(struct ast_sip_endpoint_subscription_configuration *subscription)
 {
        ast_string_field_free_memory(&subscription->mwi);