[svn-commits] russell: trunk r79862 - /trunk/channels/chan_iax2.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Aug 17 09:15:00 CDT 2007
Author: russell
Date: Fri Aug 17 09:14:59 2007
New Revision: 79862
URL: http://svn.digium.com/view/asterisk?view=rev&rev=79862
Log:
Make use of ast_sched_replace() in some places in chan_iax2
Modified:
trunk/channels/chan_iax2.c
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=79862&r1=79861&r2=79862
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Fri Aug 17 09:14:59 2007
@@ -1362,12 +1362,10 @@
iaxs[x]->callno = x;
iaxs[callno] = NULL;
/* Update the two timers that should have been started */
- if (iaxs[x]->pingid > -1)
- ast_sched_del(sched, iaxs[x]->pingid);
- if (iaxs[x]->lagid > -1)
- ast_sched_del(sched, iaxs[x]->lagid);
- iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
- iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
+ iaxs[x]->pingid = ast_sched_replace(iaxs[x]->pingid, sched,
+ ping_time * 1000, send_ping, (void *)(long)x);
+ iaxs[x]->lagid = ast_sched_replace(iaxs[x]->lagid, sched,
+ lagrq_time * 1000, send_lagrq, (void *)(long)x);
if (locked)
ast_mutex_unlock(&iaxsl[callno]);
res = x;
@@ -2504,14 +2502,13 @@
when = jb_next(pvt->jb) - when;
- if(pvt->jbid > -1) ast_sched_del(sched, pvt->jbid);
-
if(when <= 0) {
/* XXX should really just empty until when > 0.. */
when = 1;
}
- pvt->jbid = ast_sched_add(sched, when, get_from_jb, CALLNO_TO_PTR(pvt->callno));
+ pvt->jbid = ast_sched_replace(pvt->jbid, sched, when, get_from_jb,
+ CALLNO_TO_PTR(pvt->callno));
/* Signal scheduler thread */
signal_condition(&sched_lock, &sched_cond);
@@ -2815,9 +2812,8 @@
if (ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS)) {
ast_copy_flags(peer, &globalflags, IAX_RTAUTOCLEAR|IAX_RTCACHEFRIENDS);
if (ast_test_flag(peer, IAX_RTAUTOCLEAR)) {
- if (peer->expire > -1)
- ast_sched_del(sched, peer->expire);
- peer->expire = ast_sched_add(sched, (global_rtautoclear) * 1000, expire_registry, (void*)peer->name);
+ peer->expire = ast_sched_replace(peer->expire, sched,
+ (global_rtautoclear) * 1000, expire_registry, (void *) peer->name);
}
AST_LIST_LOCK(&peers);
AST_LIST_INSERT_HEAD(&peers, peer, entry);
@@ -5894,9 +5890,8 @@
we are registering to
*/
reg->refresh = refresh;
- if (reg->expire > -1)
- ast_sched_del(sched, reg->expire);
- reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
+ reg->expire = ast_sched_replace(reg->expire, sched,
+ (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
if (inaddrcmp(&oldus, ®->us) || (reg->messages != oldmsgs)) {
if (reg->messages > 255)
snprintf(msgstatus, sizeof(msgstatus), " with %d new and %d old messages waiting", reg->messages & 0xff, reg->messages >> 8);
@@ -6074,10 +6069,9 @@
p->addr.sin_family = AF_INET;
p->addr.sin_addr = in;
p->addr.sin_port = htons(atoi(c));
- if (p->expire > -1)
- ast_sched_del(sched, p->expire);
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
- p->expire = ast_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, (void *)p->name);
+ p->expire = ast_sched_replace(p->expire, sched,
+ (p->expiry + 10) * 1000, expire_registry, (void *) p->name);
if (iax2_regfunk)
iax2_regfunk(p->name, 1);
register_peer_exten(p, 1);
@@ -6364,9 +6358,8 @@
if (iaxs[callno]) {
iaxs[callno]->authfail = failcode;
if (delayreject) {
- if (iaxs[callno]->authid > -1)
- ast_sched_del(sched, iaxs[callno]->authid);
- iaxs[callno]->authid = ast_sched_add(sched, 1000, auth_reject, (void *)(long)callno);
+ iaxs[callno]->authid = ast_sched_replace(iaxs[callno]->authid,
+ sched, 1000, auth_reject, (void *)(long)callno);
} else
auth_reject((void *)(long)callno);
}
@@ -6407,9 +6400,8 @@
{
struct iax_ie_data ied;
/* Auto-hangup with 30 seconds of inactivity */
- if (iaxs[callno]->autoid > -1)
- ast_sched_del(sched, iaxs[callno]->autoid);
- iaxs[callno]->autoid = ast_sched_add(sched, 30000, auto_hangup, (void *)(long)callno);
+ iaxs[callno]->autoid = ast_sched_replace(iaxs[callno]->autoid,
+ sched, 30000, auto_hangup, (void *)(long)callno);
memset(&ied, 0, sizeof(ied));
iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, dp->exten);
send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_DPREQ, 0, ied.buf, ied.pos, -1);
@@ -8757,9 +8749,8 @@
if (iaxdebug)
ast_debug(1, "Unable to send registration request for '%s' without IP address\n", reg->username);
/* Setup the next registration attempt */
- if (reg->expire > -1)
- ast_sched_del(sched, reg->expire);
- reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
+ reg->expire = ast_sched_replace(reg->expire, sched,
+ (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
return -1;
}
@@ -8773,11 +8764,9 @@
ast_debug(1, "Registration created on call %d\n", reg->callno);
iaxs[reg->callno]->reg = reg;
}
- /* Schedule the next registration attempt */
- if (reg->expire > -1)
- ast_sched_del(sched, reg->expire);
/* Setup the next registration a little early */
- reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
+ reg->expire = ast_sched_replace(reg->expire, sched,
+ (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
/* Send the request */
memset(&ied, 0, sizeof(ied));
iax_ie_append_str(&ied, IAX_IE_USERNAME, reg->username);
@@ -8831,9 +8820,8 @@
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
/* Schedule autodestruct in case they don't ever give us anything back */
- if (iaxs[callno]->autoid > -1)
- ast_sched_del(sched, iaxs[callno]->autoid);
- iaxs[callno]->autoid = ast_sched_add(sched, 15000, auto_hangup, (void *)(long)callno);
+ iaxs[callno]->autoid = ast_sched_replace(iaxs[callno]->autoid,
+ sched, 15000, auto_hangup, (void *)(long)callno);
ast_set_flag(iaxs[callno], IAX_PROVISION);
/* Got a call number now, so go ahead and send the provisioning information */
send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_PROVISION, 0, ied.buf, ied.pos, -1);
@@ -8966,16 +8954,15 @@
iaxs[peer->callno]->pingtime = peer->maxms / 4 + 1;
iaxs[peer->callno]->peerpoke = peer;
- /* Remove any pending pokeexpire task */
- if (peer->pokeexpire > -1)
- ast_sched_del(sched, peer->pokeexpire);
-
/* Queue up a new task to handle no reply */
/* If the host is already unreachable then use the unreachable interval instead */
if (peer->lastms < 0) {
- peer->pokeexpire = ast_sched_add(sched, peer->pokefreqnotok, iax2_poke_noanswer, peer);
- } else
- peer->pokeexpire = ast_sched_add(sched, DEFAULT_MAXMS * 2, iax2_poke_noanswer, peer);
+ peer->pokeexpire = ast_sched_replace(peer->pokeexpire,
+ sched, peer->pokefreqnotok, iax2_poke_noanswer, peer);
+ } else {
+ peer->pokeexpire = ast_sched_replace(peer->pokeexpire,
+ sched, DEFAULT_MAXMS * 2, iax2_poke_noanswer, peer);
+ }
/* And send the poke */
send_command(iaxs[peer->callno], AST_FRAME_IAX, IAX_COMMAND_POKE, 0, NULL, 0, -1);
More information about the svn-commits
mailing list