Fix deadlock on 3-way closing and optimize a bit with codec sync
backport: asterisk-chan-voicemngr@4ff66d8f
- fix the deadlock issue on 3-way closing.
Inside the lockpvt_lock(sub->parent)
,ast_channel_lock(ast)
after getting the rtp_stats is waiting for another lock from channel.c(ast_indicate_data)
that coming in between to be unlocked. However, the lock of(ast_indicate_data)
was waiting for thepvt_lock(sub->parent)
. - remove the extra 'unlock' in the function chan_brcm_modify_codec
ast_channel_bridge_peer
required to be unlocked which is not easy to handle here, so usingAST_LIST_TRAVERSE
instead. - optimized a bit with the condition for return in the function chan_brcm_modify_codec the condition for the incoming call that has no bridge at the time calling this function is not needed for now, as a default codec has been set based on the negotiated result when calling the local channel.
- Avoid future potential deadlock with the same reason around chan_brcm_modify_codec