summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-07-14 09:55:01 +0000
committerBenny Prijono <bennylp@teluu.com>2008-07-14 09:55:01 +0000
commitbe967a283579c6260f98bedbe01fc784aa56e10f (patch)
tree1d8957d82517dfcf8a64d2713d29a13eb549d3d3
parent6205d4c9b865b1717b1b144694438d4dabc3fdc2 (diff)
Related to ticket #518: only destroy the account and buddy pools after busy_sleep() is done, otherwise when unregistration callback is called, the callback will access accounts which are no longer valid because the pool has been destroyed
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2134 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 384e332b..d871b6fc 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -1069,15 +1069,7 @@ PJ_DEF(pj_status_t) pjsua_destroy(void)
/* Terminate all presence subscriptions. */
pjsua_pres_shutdown();
- /* Destroy pool in the buddy object */
- for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.buddy); ++i) {
- if (pjsua_var.buddy[i].pool) {
- pj_pool_release(pjsua_var.buddy[i].pool);
- pjsua_var.buddy[i].pool = NULL;
- }
- }
-
- /* Destroy accounts */
+ /* Unregister all accounts */
for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) {
if (!pjsua_var.acc[i].valid)
continue;
@@ -1085,11 +1077,6 @@ PJ_DEF(pj_status_t) pjsua_destroy(void)
if (pjsua_var.acc[i].regc) {
pjsua_acc_set_registration(i, PJ_FALSE);
}
-
- if (pjsua_var.acc[i].pool) {
- pj_pool_release(pjsua_var.acc[i].pool);
- pjsua_var.acc[i].pool = NULL;
- }
}
}
@@ -1104,6 +1091,24 @@ PJ_DEF(pj_status_t) pjsua_destroy(void)
PJ_LOG(4,(THIS_FILE, "Shutting down..."));
busy_sleep(1000);
+ PJ_LOG(4,(THIS_FILE, "Destroying..."));
+
+ /* Destroy pool in the buddy object */
+ for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.buddy); ++i) {
+ if (pjsua_var.buddy[i].pool) {
+ pj_pool_release(pjsua_var.buddy[i].pool);
+ pjsua_var.buddy[i].pool = NULL;
+ }
+ }
+
+ /* Destroy accounts */
+ for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) {
+ if (pjsua_var.acc[i].pool) {
+ pj_pool_release(pjsua_var.acc[i].pool);
+ pjsua_var.acc[i].pool = NULL;
+ }
+ }
+
pjsip_endpt_destroy(pjsua_var.endpt);
pjsua_var.endpt = NULL;
}