summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-04-18 15:41:34 -0300
committerJoshua Colp <jcolp@digium.com>2016-04-18 13:49:45 -0500
commit6cfa02394f197ee224c563a1fa3a035bdf0fd22b (patch)
tree6f2b45972a587178ce7ab6ecfe36566c36eaca97 /res
parentf06ce7f90ad39f86cea909e198f4925c5cd9ce70 (diff)
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
Diffstat (limited to 'res')
-rw-r--r--res/res_pjsip_transport_management.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/res/res_pjsip_transport_management.c b/res/res_pjsip_transport_management.c
index e4ade2b44..8ba8c2da2 100644
--- a/res/res_pjsip_transport_management.c
+++ b/res/res_pjsip_transport_management.c
@@ -24,6 +24,8 @@
#include "asterisk.h"
+#include <signal.h>
+
#include <pjsip.h>
#include <pjsip_ua.h>
@@ -93,7 +95,7 @@ static void *keepalive_transport_thread(void *data)
/* 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 +349,19 @@ static int load_module(void)
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;
}