diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-01-27 22:35:29 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-01-27 22:35:29 +0000 |
commit | ac699196f54f4a4659b605c02cfdac6c23d7d971 (patch) | |
tree | 7b27e35fa085d171969d24fcc34ee5ba0350fead /channels/chan_iax2.c | |
parent | aa9c40236ca50f5b80f7d0bdf1b649c8ed5be2e6 (diff) |
Merged revisions 100465 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r100465 | tilghman | 2008-01-27 15:59:53 -0600 (Sun, 27 Jan 2008) | 11 lines
When deleting a task from the scheduler, ignoring the return value could
possibly cause memory to be accessed after it is freed, which causes all
sorts of random memory corruption. Instead, if a deletion fails, wait a
bit and try again (noting that another thread could change our taskid
value).
(closes issue #11386)
Reported by: flujan
Patches:
20080124__bug11386.diff.txt uploaded by Corydon76 (license 14)
Tested by: Corydon76, flujan, stuarth`
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@100488 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 200a7a17e..b2a04b502 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1155,7 +1155,7 @@ static void __send_lagrq(const void *data) int callno = (long)data; /* Ping only if it's real not if it's bridged */ ast_mutex_lock(&iaxsl[callno]); - if (iaxs[callno] && iaxs[callno]->lagid != -1) { + if (iaxs[callno] && iaxs[callno]->lagid > -1) { send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1); iaxs[callno]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, data); } @@ -1568,8 +1568,7 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc static void iax2_frame_free(struct iax_frame *fr) { - if (fr->retrans > -1) - ast_sched_del(sched, fr->retrans); + AST_SCHED_DEL(sched, fr->retrans); iax_frame_free(fr); } @@ -2040,24 +2039,12 @@ static void iax2_destroy_helper(struct chan_iax2_pvt *pvt) ast_clear_flag(pvt, IAX_MAXAUTHREQ); } /* No more pings or lagrq's */ - if (pvt->pingid > -1) - ast_sched_del(sched, pvt->pingid); - pvt->pingid = -1; - if (pvt->lagid > -1) - ast_sched_del(sched, pvt->lagid); - pvt->lagid = -1; - if (pvt->autoid > -1) - ast_sched_del(sched, pvt->autoid); - pvt->autoid = -1; - if (pvt->authid > -1) - ast_sched_del(sched, pvt->authid); - pvt->authid = -1; - if (pvt->initid > -1) - ast_sched_del(sched, pvt->initid); - pvt->initid = -1; - if (pvt->jbid > -1) - ast_sched_del(sched, pvt->jbid); - pvt->jbid = -1; + AST_SCHED_DEL(sched, pvt->pingid); + AST_SCHED_DEL(sched, pvt->lagid); + AST_SCHED_DEL(sched, pvt->autoid); + AST_SCHED_DEL(sched, pvt->authid); + AST_SCHED_DEL(sched, pvt->initid); + AST_SCHED_DEL(sched, pvt->jbid); } /*! @@ -2693,8 +2680,8 @@ static void update_jbsched(struct chan_iax2_pvt *pvt) when = ast_tvdiff_ms(ast_tvnow(), pvt->rxcore); when = jb_next(pvt->jb) - when; - - if(when <= 0) { + + if (when <= 0) { /* XXX should really just empty until when > 0.. */ when = 1; } @@ -2847,10 +2834,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr jb_reset(iaxs[fr->callno]->jb); - if (iaxs[fr->callno]->jbid > -1) - ast_sched_del(sched, iaxs[fr->callno]->jbid); - - iaxs[fr->callno]->jbid = -1; + AST_SCHED_DEL(sched, iaxs[fr->callno]->jbid); /* deliver this frame now */ if (tsout) @@ -7988,11 +7972,7 @@ retryowner: } } if (f.frametype == AST_FRAME_IAX) { - if (iaxs[fr->callno]->initid > -1) { - /* Don't auto congest anymore since we've gotten something usefulb ack */ - ast_sched_del(sched, iaxs[fr->callno]->initid); - iaxs[fr->callno]->initid = -1; - } + AST_SCHED_DEL(sched, iaxs[fr->callno]->initid); /* Handle the IAX pseudo frame itself */ if (iaxdebug) ast_debug(1, "IAX subclass %d received\n", f.subclass); @@ -9966,9 +9946,7 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st } } else { /* Non-dynamic. Make sure we become that way if we're not */ - if (peer->expire > -1) - ast_sched_del(sched, peer->expire); - peer->expire = -1; + AST_SCHED_DEL(sched, peer->expire); ast_clear_flag(peer, IAX_DYNAMIC); if (ast_dnsmgr_lookup(v->value, &peer->addr.sin_addr, &peer->dnsmgr)) return peer_unref(peer); @@ -10347,8 +10325,7 @@ static void delete_users(void) AST_LIST_LOCK(®istrations); while ((reg = AST_LIST_REMOVE_HEAD(®istrations, entry))) { - if (reg->expire > -1) - ast_sched_del(sched, reg->expire); + AST_SCHED_DEL(sched, reg->expire); if (reg->callno) { ast_mutex_lock(&iaxsl[reg->callno]); if (iaxs[reg->callno]) { |