[asterisk-commits] murf: branch murf/bug11210 r104066 - in /team/murf/bug11210: channels/ includ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Feb 23 14:19:03 CST 2008
Author: murf
Date: Sat Feb 23 14:19:03 2008
New Revision: 104066
URL: http://svn.digium.com/view/asterisk?view=rev&rev=104066
Log:
Another checkpoint. updated SCHED_REPLACE_UNREF to use the find_data call; corrected an errant call in chan_sip.
Modified:
team/murf/bug11210/channels/chan_sip.c
team/murf/bug11210/include/asterisk/sched.h
Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=104066&r1=104065&r2=104066
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Sat Feb 23 14:19:03 2008
@@ -4411,8 +4411,9 @@
/* Initialize auto-congest time */
AST_SCHED_REPLACE_UNREF(p->initid, sched, p->timer_b, auto_congest, p,
- dialog_unref(p, "object ptr dec when SCHED_REPLACE del op succeeded or add failed"),
- dialog_ref(p, "object ptr inc when SCHED_REPLACE add succeeded") );
+ dialog_unref(_data, "dialog ptr dec when SCHED_REPLACE del op succeeded"),
+ dialog_unref(p, "dialog ptr dec when SCHED_REPLACE add failed"),
+ dialog_ref(p, "dialog ptr inc when SCHED_REPLACE add succeeded") );
}
return res;
}
@@ -9380,7 +9381,8 @@
p = dialog_unref(p, "unref dialog after unlink_all"); /* HUH? this might be bad! */
if (r->timeout > -1) {
AST_SCHED_REPLACE_UNREF(r->timeout, sched, global_reg_timeout * 1000, sip_reg_timeout, r,
- registry_unref(r,"del for REPLACE of registry ptr"),
+ registry_unref(_data, "del for REPLACE of registry ptr"),
+ registry_unref(r, "object ptr dec when SCHED_REPLACE add failed"),
registry_addref(r,"add for REPLACE registry ptr"));
ast_log(LOG_WARNING, "Still have a registration timeout for %s@%s (create_addr() error), %d\n", r->username, r->hostname, r->timeout);
} else {
@@ -9437,7 +9439,8 @@
if (r->timeout > -1)
ast_log(LOG_WARNING, "Still have a registration timeout, #%d - deleting it\n", r->timeout);
AST_SCHED_REPLACE_UNREF(r->timeout, sched, global_reg_timeout * 1000, sip_reg_timeout, r,
- registry_unref(r,"reg ptr unrefed from del in SCHED_REPLACE (or add failure)"),
+ registry_unref(_data,"reg ptr unrefed from del in SCHED_REPLACE"),
+ registry_unref(r,"reg ptr unrefed from add failure in SCHED_REPLACE"),
registry_addref(r,"reg ptr reffed from add in SCHED_REPLACE"));
ast_debug(1, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
}
@@ -15416,8 +15419,9 @@
/* Schedule re-registration before we expire */
AST_SCHED_REPLACE_UNREF(r->expire, sched, expires_ms, sip_reregister, r,
- registry_unref(r,"unref in REPLACE del/add fail"),
- registry_addref(r,"The Addition side of REPLACE"));
+ registry_unref(_data,"unref in REPLACE del fail"),
+ registry_unref(r,"unref in REPLACE add fail"),
+ registry_addref(r,"The Addition side of REPLACE"));
/* it is clear that we would not want to destroy the registry entry if we just
scheduled a callback and recorded it in there! */
/* since we never bumped the count, we shouldn't decrement it! registry_unref(r, "unref registry ptr r");*/ /* HUH? if this gets deleted, p->registry will be a bad pointer! */
@@ -22255,8 +22259,9 @@
ASTOBJ_WRLOCK(iterator);
ms += regspacing;
AST_SCHED_REPLACE_UNREF(iterator->expire, sched, ms, sip_reregister, iterator,
- registry_unref(iterator, "REPLACE sched del decs the refcount"),
- registry_unref(iterator, "REPLACE sched add incs the refcount"));
+ registry_unref(_data, "REPLACE sched del decs the refcount"),
+ registry_unref(iterator, "REPLACE sched add failure decs the refcount"),
+ registry_addref(iterator, "REPLACE sched add incs the refcount"));
ASTOBJ_UNLOCK(iterator);
} while (0)
);
Modified: team/murf/bug11210/include/asterisk/sched.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/include/asterisk/sched.h?view=diff&rev=104066&r1=104065&r2=104066
==============================================================================
--- team/murf/bug11210/include/asterisk/sched.h (original)
+++ team/murf/bug11210/include/asterisk/sched.h Sat Feb 23 14:19:03 2008
@@ -71,24 +71,25 @@
#define AST_SCHED_REPLACE(id, sched, when, callback, data) \
AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, 0)
-#define AST_SCHED_REPLACE_VARIABLE_UNREF(id, sched, when, callback, data, variable, unrefcall, refcall) \
+#define AST_SCHED_REPLACE_VARIABLE_UNREF(id, sched, when, callback, data, variable, unrefcall, addfailcall, refcall) \
do { \
int _count = 0, _res=1; \
+ void *_data = (void *)ast_sched_find_data(sched, id); \
while (id > -1 && (_res = ast_sched_del(sched, id) && _count++ < 10)) \
usleep(1); \
- if (!_res) \
- unrefcall; \
+ if (!_res && _data) \
+ 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__); \
id = ast_sched_add_variable(sched, when, callback, data, variable); \
if (id == -1) \
- unrefcall; \
+ addfailcall; \
else \
refcall; \
} while (0);
-#define AST_SCHED_REPLACE_UNREF(id, sched, when, callback, data, unrefcall, refcall) \
- AST_SCHED_REPLACE_VARIABLE_UNREF(id, sched, when, callback, data, 0, unrefcall, refcall)
+#define AST_SCHED_REPLACE_UNREF(id, sched, when, callback, data, unrefcall, addfailcall, refcall) \
+ AST_SCHED_REPLACE_VARIABLE_UNREF(id, sched, when, callback, data, 0, unrefcall, addfailcall, refcall)
struct sched_context;
More information about the asterisk-commits
mailing list