[Asterisk-code-review] res pjsip transport management: Allow unload to occur. (asterisk[13])

Joshua Colp asteriskteam at digium.com
Mon Apr 18 13:43:09 CDT 2016


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/2638

Change subject: res_pjsip_transport_management: Allow unload to occur.
......................................................................

res_pjsip_transport_management: Allow unload to occur.

At shutdown it is possible for modules to be unloaded that wouldn't
normally be unloaded. This allows the environment to be cleaned up.

The res_pjsip_transport_management module did not have the unload
logic in it to clean itself up causing the res_pjsip module to not
get unloaded. As a result the res_pjsip monitor thread kept going
processing traffic and timers when it shouldn't.

Change-Id: Ic8cadee131e3b2c436a81d3ae8bb5775999ae00a
---
M res/res_pjsip_transport_management.c
1 file changed, 14 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/2638/1

diff --git a/res/res_pjsip_transport_management.c b/res/res_pjsip_transport_management.c
index eb02404..a6d064d 100644
--- a/res/res_pjsip_transport_management.c
+++ b/res/res_pjsip_transport_management.c
@@ -93,7 +93,7 @@
 	/* Once loaded this module just keeps on going as it is unsafe to stop and change the underlying
 	 * callback for the transport manager.
 	 */
-	while (1) {
+	while (keepalive_interval) {
 		sleep(keepalive_interval);
 		ao2_callback(transports, OBJ_NODATA, keepalive_transport_cb, NULL);
 	}
@@ -347,7 +347,19 @@
 
 static int unload_module(void)
 {
-	/* This will never get called */
+	pjsip_tpmgr *tpmgr = pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint());
+
+	if (keepalive_interval) {
+		keepalive_interval = 0;
+		pthread_kill(keepalive_thread, SIGURG);
+		pthread_join(keepalive_thread, NULL);
+	}
+
+	ast_sched_context_destroy(sched);
+	ao2_ref(transports, -1);
+
+	ast_sip_unregister_service(&idle_monitor_module);
+	pjsip_tpmgr_set_state_cb(tpmgr, tpmgr_state_callback);
 	return 0;
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8cadee131e3b2c436a81d3ae8bb5775999ae00a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list