From 69ade72e3cc397142036db1e71d49c94daa2d43c Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Sun, 27 Jan 2008 23:14:48 +0000 Subject: With the switch to the ast_sched_replace* API in trunk, we lose the correction that was just merged from 1.4, so this is a changeover to those APIs to use the macro versions, so that we properly detect errors from ast_sched_del, instead of simply ignoring the return values. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@100497 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/sched.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/asterisk/sched.h') diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h index dbe066310..febcbce94 100644 --- a/include/asterisk/sched.h +++ b/include/asterisk/sched.h @@ -45,6 +45,19 @@ extern "C" { id = -1; \ } while (0); +#define AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, variable) \ + 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__); \ + id = ast_sched_add_variable(sched, when, callback, data, variable); \ + } while (0); + +#define AST_SCHED_REPLACE(id, sched, when, callback, data) \ + AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, 0) + struct sched_context; /*! \brief New schedule context -- cgit v1.2.3