From: Richard Mudgett Date: Tue, 15 Apr 2014 16:23:12 +0000 (+0000) Subject: chan_sip.c: Moved some sip_pvt unrefs after their last use. X-Git-Tag: 11.10.0-rc1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb3b4352ac83fe2afd21662152bfb305a076fdaa;p=thirdparty%2Fasterisk.git chan_sip.c: Moved some sip_pvt unrefs after their last use. * Moved sip_pvt unref in ast_hangup() and handle_request_do() to the end of the function. The unref needs to happen after the last use of the pointer. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@412348 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 04fd266de0..846097df7e 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7038,10 +7038,11 @@ static int sip_hangup(struct ast_channel *ast) sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Really hang up next time */ if (p->owner) { - ast_channel_tech_pvt_set(p->owner, dialog_unref(ast_channel_tech_pvt(p->owner), "unref p->owner->tech_pvt")); sip_pvt_lock(p); + oldowner = p->owner; p->owner = NULL; /* Owner will be gone after we return, so take it away */ sip_pvt_unlock(p); + ast_channel_tech_pvt_set(oldowner, dialog_unref(ast_channel_tech_pvt(oldowner), "unref oldowner->tech_pvt")); } ast_module_unref(ast_module_info->self); return 0; @@ -7077,7 +7078,7 @@ static int sip_hangup(struct ast_channel *ast) disable_dsp_detect(p); p->owner = NULL; - ast_channel_tech_pvt_set(ast, dialog_unref(ast_channel_tech_pvt(ast), "unref ast->tech_pvt")); + ast_channel_tech_pvt_set(ast, NULL); ast_module_unref(ast_module_info->self); /* Do not destroy this pvt until we have timeout or @@ -7209,6 +7210,7 @@ static int sip_hangup(struct ast_channel *ast) pvt_set_needdestroy(p, "hangup"); } sip_pvt_unlock(p); + dialog_unref(p, "unref ast->tech_pvt"); return 0; } @@ -28550,12 +28552,12 @@ static int handle_request_do(struct sip_request *req, struct ast_sockaddr *addr) ast_channel_unref(owner_chan_ref); } sip_pvt_unlock(p); - ao2_t_ref(p, -1, "throw away dialog ptr from find_call at end of routine"); /* p is gone after the return */ ast_mutex_unlock(&netlock); if (p->logger_callid) { ast_callid_threadassoc_remove(); } + ao2_t_ref(p, -1, "throw away dialog ptr from find_call at end of routine"); /* p is gone after the return */ return 1; }