Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 383905) +++ channels/chan_sip.c (working copy) @@ -28803,7 +28803,19 @@ if (res > 20) { ast_debug(1, "chan_sip: ast_io_wait ran %d all at once\n", res); } - ast_mutex_lock(&monlock); + res = 5; + while (ast_mutex_trylock(&monlock)) { + pthread_testcancel(); + sched_yield(); + --res; + if (res < 0) { + break; + } + } + if (res < 0) { + ast_debug(1, "chan_sip: ast_mutex_trylock(&monlock) has failed, not running sched this loop\n"); + continue; + } res = ast_sched_runq(sched); if (res >= 20) { ast_debug(1, "chan_sip: ast_sched_runq ran %d all at once\n", res);