From 95ba3fa4501e8e7a6769d29f54025dc614455b9b Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 16 Sep 2011 03:12:27 +0000 Subject: Fixed #1371: Soft deadlock when application query call info of other call inside a callback. The following APIs should be safe to be called in this situation: - pjsua_call_get_info() - pjsua_call_get_conf_port() git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3751 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_call.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'pjsip/src/pjsua-lib') diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index acfcd359..1e29634a 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -1242,19 +1242,19 @@ PJ_DEF(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id) { pjsua_call *call; pjsua_conf_port_id port_id; - pjsip_dialog *dlg; - pj_status_t status; PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, PJ_EINVAL); - status = acquire_call("pjsua_call_get_conf_port()", call_id, &call, &dlg); - if (status != PJ_SUCCESS) - return PJSUA_INVALID_ID; + /* Use PJSUA_LOCK() instead of acquire_call(): + * https://trac.pjsip.org/repos/ticket/1371 + */ + PJSUA_LOCK(); + call = &pjsua_var.calls[call_id]; port_id = call->conf_slot; - pjsip_dlg_dec_lock(dlg); + PJSUA_UNLOCK(); return port_id; } @@ -1268,18 +1268,18 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id, pjsua_call_info *info) { pjsua_call *call; - pjsip_dialog *dlg; - pj_status_t status; PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, PJ_EINVAL); pj_bzero(info, sizeof(*info)); - status = acquire_call("pjsua_call_get_info()", call_id, &call, &dlg); - if (status != PJ_SUCCESS) { - return status; - } + /* Use PJSUA_LOCK() instead of acquire_call(): + * https://trac.pjsip.org/repos/ticket/1371 + */ + PJSUA_LOCK(); + + call = &pjsua_var.calls[call_id]; /* id and role */ info->id = call_id; @@ -1375,7 +1375,7 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id, PJ_TIME_VAL_SUB(info->total_duration, call->start_time); } - pjsip_dlg_dec_lock(dlg); + PJSUA_UNLOCK(); return PJ_SUCCESS; } -- cgit v1.2.3