[asterisk-commits] coreyfarrell: trunk r433470 - in /trunk: ./ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 26 12:47:45 CDT 2015


Author: coreyfarrell
Date: Thu Mar 26 12:47:42 2015
New Revision: 433470

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433470
Log:
res_pjsip: Enable unload of all modules at shutdown.

* Move most of res_pjsip:module_unload to unload_pjsip to resolve crashes
  caused by running PJSIP functions from non-PJSIP threads.
* Remove call to pjsip_endpt_destroy(ast_pjsip_endpoint), it was causing
  crashes in some cases.  In theory pj_shutdown() should take care of this.
* Mark res_pjsip_keepalive and res_pjsip_session as allowed to unload at
  shutdown.
* Resolve leaked config global in res_pjsip_notify.
* Unregister pubsub pjsip service module.
* Implement cleanup for res_pjsip_session.

ASTERISK-24731 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4498/
........

Merged revisions 433469 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip.c
    trunk/res/res_pjsip_keepalive.c
    trunk/res/res_pjsip_notify.c
    trunk/res/res_pjsip_pubsub.c
    trunk/res/res_pjsip_session.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip.c?view=diff&rev=433470&r1=433469&r2=433470
==============================================================================
--- trunk/res/res_pjsip.c (original)
+++ trunk/res/res_pjsip.c Thu Mar 26 12:47:42 2015
@@ -3520,21 +3520,6 @@
 static int unload_pjsip(void *data)
 {
 	ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
-	if (memory_pool) {
-		pj_pool_release(memory_pool);
-		memory_pool = NULL;
-	}
-	if (ast_pjsip_endpoint) {
-		pjsip_endpt_destroy(ast_pjsip_endpoint);
-		ast_pjsip_endpoint = NULL;
-	}
-	pj_caching_pool_destroy(&caching_pool);
-	pj_shutdown();
-	return 0;
-}
-
-static int unload_module(void)
-{
 	ast_res_pjsip_cleanup_options_handling();
 	internal_sip_destroy_outbound_authentication();
 	ast_sip_destroy_distributor();
@@ -3545,6 +3530,18 @@
 	if (monitor_thread) {
 		stop_monitor_thread();
 	}
+	if (memory_pool) {
+		pj_pool_release(memory_pool);
+		memory_pool = NULL;
+	}
+	ast_pjsip_endpoint = NULL;
+	pj_caching_pool_destroy(&caching_pool);
+	pj_shutdown();
+	return 0;
+}
+
+static int unload_module(void)
+{
 	/* The thread this is called from cannot call PJSIP/PJLIB functions,
 	 * so we have to push the work to the threadpool to handle
 	 */

Modified: trunk/res/res_pjsip_keepalive.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_keepalive.c?view=diff&rev=433470&r1=433469&r2=433470
==============================================================================
--- trunk/res/res_pjsip_keepalive.c (original)
+++ trunk/res/res_pjsip_keepalive.c Thu Mar 26 12:47:42 2015
@@ -244,7 +244,7 @@
 
 	ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &keepalive_global_observer);
 	ast_sorcery_reload_object(ast_sip_get_sorcery(), "global");
-	ast_module_ref(ast_module_info->self);
+	ast_module_shutdown_ref(ast_module_info->self);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: trunk/res/res_pjsip_notify.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_notify.c?view=diff&rev=433470&r1=433469&r2=433470
==============================================================================
--- trunk/res/res_pjsip_notify.c (original)
+++ trunk/res/res_pjsip_notify.c Thu Mar 26 12:47:42 2015
@@ -1021,6 +1021,7 @@
 	ast_manager_unregister("PJSIPNotify");
 	ast_cli_unregister_multiple(cli_options, ARRAY_LEN(cli_options));
 	aco_info_destroy(&notify_cfg);
+	ao2_global_obj_release(globals);
 
 	return 0;
 }

Modified: trunk/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_pubsub.c?view=diff&rev=433470&r1=433469&r2=433470
==============================================================================
--- trunk/res/res_pjsip_pubsub.c (original)
+++ trunk/res/res_pjsip_pubsub.c Thu Mar 26 12:47:42 2015
@@ -4286,6 +4286,7 @@
 	ast_manager_unregister(AMI_SHOW_SUBSCRIPTIONS_INBOUND);
 	ast_manager_unregister("PJSIPShowResourceLists");
 
+	ast_sip_unregister_service(&pubsub_module);
 	if (sched) {
 		ast_sched_context_destroy(sched);
 	}

Modified: trunk/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_session.c?view=diff&rev=433470&r1=433469&r2=433470
==============================================================================
--- trunk/res/res_pjsip_session.c (original)
+++ trunk/res/res_pjsip_session.c Thu Mar 26 12:47:42 2015
@@ -2641,14 +2641,18 @@
 	}
 	ast_sip_register_service(&session_reinvite_module);
 
-	ast_module_ref(ast_module_info->self);
+	ast_module_shutdown_ref(ast_module_info->self);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int unload_module(void)
 {
-	/* This will never get called as this module can't be unloaded */
+	ast_sip_unregister_service(&session_reinvite_module);
+	ast_sip_unregister_service(&session_module);
+	ast_sorcery_delete(ast_sip_get_sorcery(), nat_hook);
+	ao2_cleanup(nat_hook);
+	ao2_cleanup(sdp_handlers);
 	return 0;
 }
 




More information about the asterisk-commits mailing list