Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 131970) +++ channels/chan_iax2.c (working copy) @@ -1306,8 +1306,8 @@ } } if (!owner && iaxs[callno]) { - AST_SCHED_DEL(sched, iaxs[callno]->lagid); - AST_SCHED_DEL(sched, iaxs[callno]->pingid); + AST_SCHED_DEL_SPINLOCK(sched, iaxs[callno]->lagid, &iaxsl[callno]); + AST_SCHED_DEL_SPINLOCK(sched, iaxs[callno]->pingid, &iaxsl[callno]); iaxs[callno] = NULL; } Index: include/asterisk/sched.h =================================================================== --- include/asterisk/sched.h (revision 131985) +++ include/asterisk/sched.h (working copy) @@ -60,6 +60,22 @@ (_sched_res); \ }) +#define AST_SCHED_DEL_SPINLOCK(sched, id, lock) \ + ({ \ + int _count = 0; \ + int _sched_res = -1; \ + while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) { \ + ast_mutex_unlock(lock); \ + usleep(1); \ + ast_mutex_lock(lock); \ + } \ + if (_count == 10 && option_debug > 2) { \ + ast_log(LOG_DEBUG, "Unable to cancel schedule ID %d.\n", id); \ + } \ + id = -1; \ + (_sched_res); \ + }) + struct sched_context; /*! \brief New schedule context