Skip to content

Fix a dead lock and remove some duplicated indications during un-hold

Wenpeng Song requested to merge fix-unhold-ubus-stuck into release-7.3
  • Fix a dead lock during un-hold procedure under race condition by.
    • Remove duplicated indications for un-hold.
    • Narrow the usage of channel lock inside chan_voicemngr_modify_codec
    • Remove the extra redirection for the case from: !26 (merged) as it is not needed for now.

The dead lock is due to ast_channel_get_by_name used by chan_voicemngr_modify_codec(which called during ssrc related indications) https://dev.iopsys.eu/voice/asterisk-chan-voicemngr/-/blob/devel/src/channels/chan_voicemngr.c#L774 has a channel lock from ast_channel_by_name_cb. And indications for different channels also have locks from ast_indicate_data. They may waiting for each other during some massive indications between bridged channels.

=======================================================================
=== 20.3.0
=== Currently Held Locks
=======================================================================
===
=== <pending> <lock#> (<file>): <lock type> <line num> <function> <lock name> <lock addr> (times locked)
===
=== Thread ID: 0xb592dd6c LWP:18222 (pe_base_run          started at [ 5233] chan_voicemngr.c load_module())
=== ---> Waiting for Lock #0 (channel.c): MUTEX 1019 __ast_queue_frame chan 0xb4f375d8 (1)
=== --- ---> Locked Here: channel.c line 4709 (ast_indicate_data)
=== --- ---> Locked Here: chan_voicemngr.c line 767 (chan_voicemngr_modify_codec)
=== -------------------------------------------------------------------
===
=== Thread ID: 0xb555ed6c LWP:18233 (worker_start         started at [ 1111] threadpool.c worker_thread_start())
=== ---> Waiting for Lock #0 (channel.c): MUTEX 1019 __ast_queue_frame chan 0xb4f130b8 (1)
=== --- ---> Locked Here: chan_pjsip.c line 1828 (chan_pjsip_indicate)
=== -------------------------------------------------------------------
===
=== Thread ID: 0xb4db2d6c LWP:18416 (pbx_thread           started at [ 4733] pbx.c ast_pbx_start())
=== ---> Lock #0 (channel.c): MUTEX 4709 ast_indicate_data chan 0xb4f375d8 (2)
=== ---> Lock #1 (astobj2_container.c): MUTEX 310 internal_ao2_traverse self 0xb63a74f8 (1)
=== ---> Waiting for Lock #2 (channel.c): MUTEX 1290 ast_channel_by_name_cb chan 0xb4f130b8 (1)
=== --- ---> Locked Here: chan_pjsip.c line 1828 (chan_pjsip_indicate)
=== -------------------------------------------------------------------
===
=== Thread ID: 0xb6515d6c LWP:18503 (bridge_channel_ind_thread started at [ 1845] bridge.c bridge_impart_internal())
=== ---> Lock #0 (chan_pjsip.c): MUTEX 1828 chan_pjsip_indicate ast 0xb4f130b8 (1)
=== ---> Waiting for Lock #1 (channel.c): MUTEX 4709 ast_indicate_data chan 0xb4f375d8 (1)
=== --- ---> Locked Here: channel.c line 4709 (ast_indicate_data)
=== --- ---> Locked Here: chan_voicemngr.c line 767 (chan_voicemngr_modify_codec)
=== -------------------------------------------------------------------
===
=======================================================================
Edited by Wenpeng Song

Merge request reports