diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h index 6c2f9f8655..f262331714 100644 --- a/include/asterisk/sched.h +++ b/include/asterisk/sched.h @@ -70,42 +70,23 @@ extern "C" { }) /*! - * \brief schedule task to get deleted and call unref function + * \brief schedule task to get deleted and call unref function if delete succeeds * \sa AST_SCHED_DEL * \since 1.6.1 */ #define AST_SCHED_DEL_UNREF(sched, id, refcall) \ do { \ - int _count = 0; \ - while (id > -1 && ast_sched_del(sched, id) && ++_count < 10) { \ - usleep(1); \ - } \ - if (_count == 10) \ - ast_log(LOG_WARNING, "Unable to cancel schedule ID %d. This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ - if (id > -1) \ - refcall; \ - id = -1; \ - } while (0); - -/*! - * \brief schedule task to get deleted releasing the lock between attempts - * \since 1.6.1 - */ -#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); \ + int _count = 0, _id = id; \ + while (_id > -1 && ast_sched_del(sched, _id) && ++_count < 10) { \ usleep(1); \ - ast_mutex_lock(lock); \ } \ if (_count == 10) { \ - ast_debug(3, "Unable to cancel schedule ID %d.\n", id); \ + ast_log(LOG_WARNING, "Unable to cancel schedule ID %d. This is probably a bug (%s: %s, line %d).\n", _id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ + } else if (_id > -1) { \ + refcall; \ + id = -1; \ } \ - id = -1; \ - (_sched_res); \ - }) + } while (0); #define AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, variable) \ do { \