aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-17 13:37:08 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-17 13:37:08 +0000
commitf2ffdcf8e9fd70d84c57bc6debe152357087a89f (patch)
tree1255280e2e50f66f69e8ba17a8167d7a60a18685
parentfea9ace809a136593a202bdd55d4e615b64eadfe (diff)
Fix some crashes in chan_sip. This patch changes various places that add items
to the scheduler to ensure that they don't overwrite the ID of a previously scheduled item. If there is one, it should be removed. (closes issue #10391, closes issue #10256, probably others, patch by me) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@79857 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index edb5d4266..9b41cd680 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2013,6 +2013,8 @@ static enum sip_result __sip_reliable_xmit(struct sip_pvt *p, int seqno, int res
siptimer_a = pkt->timer_t1 * 2;
/* Schedule retransmission */
+ if (pkt->retransid > -1)
+ ast_sched_del(sched, pkt->retransid);
pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
if (option_debug > 3 && sipdebug)
ast_log(LOG_DEBUG, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
@@ -2954,6 +2956,8 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
p->invitestate = INV_CALLING;
/* Initialize auto-congest time */
+ if (p->initid > -1)
+ ast_sched_del(sched, p->initid);
p->initid = ast_sched_add(sched, p->maxtime ? (p->maxtime * 4) : SIP_TRANS_TIMEOUT, auto_congest, p);
}
}
@@ -12268,7 +12272,9 @@ static int handle_response_register(struct sip_pvt *p, int resp, char *rest, str
r->refresh= (int) expires_ms / 1000;
/* Schedule re-registration before we expire */
- r->expire=ast_sched_add(sched, expires_ms, sip_reregister, r);
+ if (r->expire > -1)
+ ast_sched_del(sched, r->expire);
+ r->expire = ast_sched_add(sched, expires_ms, sip_reregister, r);
ASTOBJ_UNREF(r, sip_registry_destroy);
}
return 1;
@@ -15422,6 +15428,8 @@ static int sip_poke_noanswer(void *data)
peer->lastms = -1;
ast_device_state_changed("SIP/%s", peer->name);
/* Try again quickly */
+ if (peer->pokeexpire > -1)
+ ast_sched_del(sched, peer->pokeexpire);
peer->pokeexpire = ast_sched_add(sched, DEFAULT_FREQ_NOTOK, sip_poke_peer_s, peer);
return 0;
}
@@ -15485,8 +15493,11 @@ static int sip_poke_peer(struct sip_peer *peer)
gettimeofday(&peer->ps, NULL);
if (xmitres == XMIT_ERROR)
sip_poke_noanswer(peer); /* Immediately unreachable, network problems */
- else
+ else {
+ if (peer->pokeexpire > -1)
+ ast_sched_del(sched, peer->pokeexpire);
peer->pokeexpire = ast_sched_add(sched, DEFAULT_MAXMS * 2, sip_poke_noanswer, peer);
+ }
return 0;
}