aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_mgcp.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-27 21:59:53 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-27 21:59:53 +0000
commit940f913146cc96cda9132600151d40ee85680ee6 (patch)
treea0610b66a954f2b2f98aedcd42cbc2b4250184b8 /channels/chan_mgcp.c
parent74e414e5f2dbf490e4c2f67ce638e0ec9e4ad0ae (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@100465 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_mgcp.c')
-rw-r--r--channels/chan_mgcp.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 4c2fa9b41..821af684a 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -3397,9 +3397,8 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
}
/* stop retrans timer if the queue is empty */
- if (!gw->msgs && (gw->retransid != -1)) {
- ast_sched_del(sched, gw->retransid);
- gw->retransid = -1;
+ if (!gw->msgs) {
+ AST_SCHED_DEL(sched, gw->retransid);
}
ast_mutex_unlock(&gw->msgs_lock);
@@ -3655,9 +3654,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
}
} else {
/* Non-dynamic. Make sure we become that way if we're not */
- if (gw->expire > -1)
- ast_sched_del(sched, gw->expire);
- gw->expire = -1;
+ AST_SCHED_DEL(sched, gw->expire);
gw->dynamic = 0;
if (ast_get_ip(&gw->addr, v->value)) {
if (!gw_reload) {