summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-11-02 08:48:06 +0000
committerBenny Prijono <bennylp@teluu.com>2011-11-02 08:48:06 +0000
commit50bc012d7a4b979acd073eca17b31b1fe8361adf (patch)
treeeb65af3a0aa97d964da20934d8252ba4aa8ca988
parenta7e2db80515427b79ac3432c1f77e606c63e1ba7 (diff)
Fixed #1415: Handle potential crash if joining worker thread fails in pjsua_destroy()
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3882 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index d292122a..4538d841 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -1291,13 +1291,20 @@ PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags)
{
int i; /* Must be signed */
+ PJ_LOG(4,(THIS_FILE, "Shutting down, flags=%d...", flags));
+
/* Signal threads to quit: */
pjsua_var.thread_quit_flag = 1;
/* Wait worker threads to quit: */
for (i=0; i<(int)pjsua_var.ua_cfg.thread_cnt; ++i) {
if (pjsua_var.thread[i]) {
- pj_thread_join(pjsua_var.thread[i]);
+ pj_status_t status;
+ status = pj_thread_join(pjsua_var.thread[i]);
+ if (status != PJ_SUCCESS) {
+ PJ_PERROR(4,(THIS_FILE, status, "Error joining worker thread"));
+ pj_thread_sleep(1000);
+ }
pj_thread_destroy(pjsua_var.thread[i]);
pjsua_var.thread[i] = NULL;
}
@@ -1306,8 +1313,6 @@ PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags)
if (pjsua_var.endpt) {
unsigned max_wait;
- PJ_LOG(4,(THIS_FILE, "Shutting down, flags=%d...", flags));
-
/* Terminate all calls. */
if ((flags & PJSUA_DESTROY_NO_TX_MSG) == 0) {
pjsua_call_hangup_all();