aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-30 19:31:40 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-30 19:31:40 +0000
commitdc51571710fc534f5143f35927bfff6ebc2e0604 (patch)
treea12dc3f2f57cb6638c4be87ca6cc05f6946401fc
parentd6123b0608375023c02bc2c5ac49c663cfcc673e (diff)
Merged revisions 152887 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r152887 | russell | 2008-10-30 14:28:06 -0500 (Thu, 30 Oct 2008) | 7 lines Fix a bug in AST_SCHED_REPLACE_UNREF(). The reference count of the object _must_ be increased before creating the scheduler entry. Otherwise, you create a race condition where the reference count may hit zero and the object can disappear out from under you. This could also would have incorrectly decreased the reference count in the case that the scheduler add failed. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@152900 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--include/asterisk/sched.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h
index 92a5d76a4..ab328af95 100644
--- a/include/asterisk/sched.h
+++ b/include/asterisk/sched.h
@@ -113,11 +113,10 @@ extern "C" {
unrefcall; /* should ref _data! */ \
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__); \
+ refcall; \
id = ast_sched_add_variable(sched, when, callback, data, variable); \
if (id == -1) \
addfailcall; \
- else \
- refcall; \
} while (0);
#define AST_SCHED_REPLACE_UNREF(id, sched, when, callback, data, unrefcall, addfailcall, refcall) \