[asterisk-commits] russell: branch russell/sched_thread r170834 - in /team/russell/sched_thread:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jan 23 23:18:42 CST 2009
Author: russell
Date: Fri Jan 23 23:18:42 2009
New Revision: 170834
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=170834
Log:
Resolve an old conflict and change how sched_thread_del works
Modified:
team/russell/sched_thread/ (props changed)
team/russell/sched_thread/channels/chan_iax2.c
team/russell/sched_thread/include/asterisk/sched.h
team/russell/sched_thread/main/sched.c
Propchange: team/russell/sched_thread/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.
Propchange: team/russell/sched_thread/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jan 23 23:18:42 2009
@@ -1,1 +1,1 @@
-/trunk:1-150542
+/trunk:1-150629
Modified: team/russell/sched_thread/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/sched_thread/channels/chan_iax2.c?view=diff&rev=170834&r1=170833&r2=170834
==============================================================================
--- team/russell/sched_thread/channels/chan_iax2.c (original)
+++ team/russell/sched_thread/channels/chan_iax2.c Fri Jan 23 23:18:42 2009
@@ -1405,6 +1405,8 @@
return res;
}
+/*!\note Assumes the lock on the pvt is already held, when
+ * iax2_destroy_helper() is called. */
static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
{
/* Decrement AUTHREQ count if needed */
@@ -1423,8 +1425,8 @@
ast_clear_flag(pvt, IAX_MAXAUTHREQ);
}
/* No more pings or lagrq's */
- ast_sched_thread_del(sched, pvt->pingid);
- ast_sched_thread_del(sched, pvt->lagid);
+ AST_SCHED_DEL_SPINLOCK(ast_sched_thread_get_context(sched), pvt->pingid, &iaxsl[pvt->callno]);
+ AST_SCHED_DEL_SPINLOCK(ast_sched_thread_get_context(sched), pvt->lagid, &iaxsl[pvt->callno]);
ast_sched_thread_del(sched, pvt->autoid);
ast_sched_thread_del(sched, pvt->authid);
ast_sched_thread_del(sched, pvt->initid);
@@ -1443,7 +1445,9 @@
struct chan_iax2_pvt *pvt = obj;
struct iax_frame *cur = NULL;
+ ast_mutex_lock(&iaxsl[pvt->callno]);
iax2_destroy_helper(pvt);
+ ast_mutex_unlock(&iaxsl[pvt->callno]);
/* Already gone */
ast_set_flag(pvt, IAX_ALREADYGONE);
@@ -2302,6 +2306,8 @@
retry:
pvt = iaxs[callno];
+ iax2_destroy_helper(pvt);
+
lastused[callno] = ast_tvnow();
owner = pvt ? pvt->owner : NULL;
Modified: team/russell/sched_thread/include/asterisk/sched.h
URL: http://svn.digium.com/svn-view/asterisk/team/russell/sched_thread/include/asterisk/sched.h?view=diff&rev=170834&r1=170833&r2=170834
==============================================================================
--- team/russell/sched_thread/include/asterisk/sched.h (original)
+++ team/russell/sched_thread/include/asterisk/sched.h Fri Jan 23 23:18:42 2009
@@ -73,6 +73,22 @@
refcall; \
id = -1; \
} while (0);
+
+#define AST_SCHED_DEL_SPINLOCK(sched, id, lock) \
+ ({ \
+ int _count = 0; \
+ int _sched_res = -1; \
+ while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) { \
+ ast_mutex_unlock(lock); \
+ usleep(1); \
+ ast_mutex_lock(lock); \
+ } \
+ if (_count == 10 && option_debug > 2) { \
+ ast_log(LOG_DEBUG, "Unable to cancel schedule ID %d.\n", id); \
+ } \
+ id = -1; \
+ (_sched_res); \
+ })
#define AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, variable) \
do { \
@@ -284,10 +300,12 @@
int ast_sched_thread_add_variable(struct ast_sched_thread *st, int when, ast_sched_cb cb,
const void *data, int variable);
-int ast_sched_thread_del(struct ast_sched_thread *st, int id);
-
-/*! XXX I hate this and want it to go away eventually */
struct sched_context *ast_sched_thread_get_context(struct ast_sched_thread *st);
+
+#define ast_sched_thread_del(st, id) ({ \
+ struct sched_context *__tmp_context = ast_sched_thread_get_context(st); \
+ AST_SCHED_DEL(__tmp_context, id); \
+})
long ast_sched_thread_when(struct ast_sched_thread *st, int id);
Modified: team/russell/sched_thread/main/sched.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/sched_thread/main/sched.c?view=diff&rev=170834&r1=170833&r2=170834
==============================================================================
--- team/russell/sched_thread/main/sched.c (original)
+++ team/russell/sched_thread/main/sched.c Fri Jan 23 23:18:42 2009
@@ -218,11 +218,6 @@
}
return res;
-}
-
-int ast_sched_thread_del(struct ast_sched_thread *st, int id)
-{
- return AST_SCHED_DEL(st->context, id);
}
/* hash routines for sched */
More information about the asterisk-commits
mailing list