aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/sched.h
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-22 15:20:37 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-22 15:20:37 +0000
commitcc4017b46708fb733db20381686221a3a00286cf (patch)
treedbd1513aa05a21d562ad9b2ed0746b282b7ac983 /include/asterisk/sched.h
parent39246bc3ad94943e0a1626da66d0d239e7839600 (diff)
Merge changes from team/russell/issue_9520
These changes make sure that the reference count for sip_peer objects properly reflects the fact that the peer is sitting in the scheduler for a scheduled callback for qualifying peers or for expiring registrations. Without this, it was possible for these callbacks to happen at the same time that the peer was being destroyed. This was especially likely to happen with realtime peers, and for people making use of the realtime prune CLI command. (closes issue #9520) Reported by: kryptolus Committed patch by me git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114522 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/sched.h')
-rw-r--r--include/asterisk/sched.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/asterisk/sched.h b/include/asterisk/sched.h
index d80beb5bc..829a1b0f6 100644
--- a/include/asterisk/sched.h
+++ b/include/asterisk/sched.h
@@ -54,14 +54,17 @@ extern "C" {
* macro should NOT be used.
*/
#define AST_SCHED_DEL(sched, id) \
- do { \
+ ({ \
int _count = 0; \
- while (id > -1 && ast_sched_del(sched, id) && ++_count < 10) \
+ int _sched_res = -1; \
+ while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) \
usleep(1); \
- if (_count == 10 && option_debug > 2) \
+ if (_count == 10 && option_debug > 2) { \
ast_log(LOG_DEBUG, "Unable to cancel schedule ID %d.\n", id); \
+ } \
id = -1; \
- } while (0);
+ (_sched_res); \
+ })
struct sched_context;