mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
core_local: local channel data not being properly unref'ed and unlocked
In an earlier version of Asterisk a local channel [un]lock all functions were added in order to keep a crash from occurring when a channel hung up too early during an attended transfer. Unfortunately, when a transfer failure occurs and depending on the timing, the local channels sometime do not get properly unlocked and deref'ed after being locked and ref'ed. This happens because the underlying local channel structure gets NULLed out before unlocking. This patch reworks those [un]lock functions and makes sure the values that get locked and ref'ed later get unlocked and deref'ed. ASTERISK-27074 #close Change-Id: Ice96653e29bd9d6674ed5f95feb6b448ab148b09
This commit is contained in:
@@ -4276,14 +4276,15 @@ static enum ast_transfer_result attended_transfer_bridge(struct ast_channel *cha
|
||||
BRIDGE_LOCK_ONE_OR_BOTH(bridge1, bridge2);
|
||||
|
||||
if (bridge2) {
|
||||
void *tech;
|
||||
struct ast_channel *locals[2];
|
||||
|
||||
/* Have to lock everything just in case a hangup comes in early */
|
||||
ast_local_lock_all(local_chan, &locals[0], &locals[1]);
|
||||
ast_local_lock_all(local_chan, &tech, &locals[0], &locals[1]);
|
||||
if (!locals[0] || !locals[1]) {
|
||||
ast_log(LOG_ERROR, "Transfer failed probably due to an early hangup - "
|
||||
"missing other half of '%s'\n", ast_channel_name(local_chan));
|
||||
ast_local_unlock_all(local_chan);
|
||||
ast_local_unlock_all(tech, locals[0], locals[1]);
|
||||
ao2_cleanup(local_chan);
|
||||
return AST_BRIDGE_TRANSFER_FAIL;
|
||||
}
|
||||
@@ -4294,7 +4295,7 @@ static enum ast_transfer_result attended_transfer_bridge(struct ast_channel *cha
|
||||
}
|
||||
|
||||
ast_attended_transfer_message_add_link(transfer_msg, locals);
|
||||
ast_local_unlock_all(local_chan);
|
||||
ast_local_unlock_all(tech, locals[0], locals[1]);
|
||||
} else {
|
||||
ast_attended_transfer_message_add_app(transfer_msg, app, local_chan);
|
||||
}
|
||||
|
Reference in New Issue
Block a user