diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h index 60a6605630..594f05a27f 100644 --- a/include/asterisk/sched.h +++ b/include/asterisk/sched.h @@ -79,13 +79,13 @@ extern "C" { */ #define AST_SCHED_DEL_UNREF(sched, id, refcall) \ do { \ - int _count = 0, _id; \ - while ((_id = id) > -1 && ast_sched_del(sched, _id) && ++_count < 10) { \ + int _count = 0, _id, _ret = 0; \ + while ((_id = id) > -1 && (( _ret = ast_sched_del(sched, _id)) == -1) && ++_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__); \ - } else if (_id > -1) { \ + } else if (_id > -1 && _ret >-2) { \ refcall; \ id = -1; \ } \ @@ -287,7 +287,7 @@ const void *ast_sched_find_data(struct ast_sched_context *con, int id); * \param con scheduling context to delete item from * \param id ID of the scheduled item to delete * - * \return Returns 0 on success, -1 on failure + * \return Returns 0 on success, -1 on failure, -2 if the event was running and not rescheduled */ int ast_sched_del(struct ast_sched_context *con, int id) attribute_warn_unused_result;