From: Joshua Colp Date: Wed, 30 Apr 2014 20:38:35 +0000 (+0000) Subject: chan_pjsip: Fix deadlock when retrieving call-id of channel. X-Git-Tag: 12.3.0-rc1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7956cdb8304cdee699389bfff80a39c9513f94e;p=thirdparty%2Fasterisk.git chan_pjsip: Fix deadlock when retrieving call-id of channel. If a task was in-flight which required the channel or bridge lock it was possible for the synchronous task retrieving the call-id to deadlock as it holds those locks. After discussing with Mark Michelson the synchronous task was removed and the call-id accessed directly. This should be safe as each object involved is guaranteed to exist and the call-id will never change. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@413140 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c index 5781504289..8d347e7a06 100644 --- a/channels/chan_pjsip.c +++ b/channels/chan_pjsip.c @@ -907,34 +907,18 @@ static int chan_pjsip_queryoption(struct ast_channel *ast, int option, void *dat return res; } -struct uniqueid_data { - struct ast_sip_session *session; - char *uniqueid; -}; - -static int get_uniqueid(void *data) -{ - struct uniqueid_data *uid_data = data; - - ast_copy_pj_str(uid_data->uniqueid, &uid_data->session->inv_session->dlg->call_id->id, UNIQUEID_BUFSIZE); - - return 0; -} - static const char *chan_pjsip_get_uniqueid(struct ast_channel *ast) { struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast); - struct uniqueid_data uid_data = { - .session = channel->session, - .uniqueid = ast_threadstorage_get(&uniqueid_threadbuf, UNIQUEID_BUFSIZE), - }; + char *uniqueid = ast_threadstorage_get(&uniqueid_threadbuf, UNIQUEID_BUFSIZE); - if (!uid_data.uniqueid || - ast_sip_push_task_synchronous(channel->session->serializer, get_uniqueid, &uid_data)) { - return NULL; + if (!uniqueid) { + return ""; } - return uid_data.uniqueid; + ast_copy_pj_str(uniqueid, &channel->session->inv_session->dlg->call_id->id, UNIQUEID_BUFSIZE); + + return uniqueid; } struct indicate_data {