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 /main | |
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 'main')
-rw-r--r-- | main/cdr.c | 8 | ||||
-rw-r--r-- | main/dnsmgr.c | 5 | ||||
-rw-r--r-- | main/file.c | 8 | ||||
-rw-r--r-- | main/rtp.c | 24 |
4 files changed, 13 insertions, 32 deletions
diff --git a/main/cdr.c b/main/cdr.c index 028e0eb14..85545be62 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -1139,8 +1139,7 @@ static int submit_scheduled_batch(const void *data) static void submit_unscheduled_batch(void) { /* this is okay since we are not being called from within the scheduler */ - if (cdr_sched > -1) - ast_sched_del(sched, cdr_sched); + AST_SCHED_DEL(sched, cdr_sched); /* schedule the submission to occur ASAP (1 ms) */ cdr_sched = ast_sched_add(sched, 1, submit_scheduled_batch, NULL); /* signal the do_cdr thread to wakeup early and do some work (that lazy thread ;) */ @@ -1332,8 +1331,7 @@ static int do_reload(int reload) batchmode = 0; /* don't run the next scheduled CDR posting while reloading */ - if (cdr_sched > -1) - ast_sched_del(sched, cdr_sched); + AST_SCHED_DEL(sched, cdr_sched); if (config) { if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) { @@ -1386,7 +1384,7 @@ static int do_reload(int reload) ast_cond_init(&cdr_pending_cond, NULL); if (ast_pthread_create_background(&cdr_thread, NULL, do_cdr, NULL) < 0) { ast_log(LOG_ERROR, "Unable to start CDR thread.\n"); - ast_sched_del(sched, cdr_sched); + AST_SCHED_DEL(sched, cdr_sched); } else { ast_cli_register(&cli_submit); ast_register_atexit(ast_cdr_engine_term); diff --git a/main/dnsmgr.c b/main/dnsmgr.c index ed2426c2e..0989f6315 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -239,7 +239,7 @@ static int refresh_list(const void *data) void dnsmgr_start_refresh(void) { if (refresh_sched > -1) { - ast_sched_del(sched, refresh_sched); + AST_SCHED_DEL(sched, refresh_sched); refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); } } @@ -371,8 +371,7 @@ static int do_reload(int loading) was_enabled = enabled; enabled = 0; - if (refresh_sched > -1) - ast_sched_del(sched, refresh_sched); + AST_SCHED_DEL(sched, refresh_sched); if (config) { if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) { diff --git a/main/file.c b/main/file.c index fe51c2df7..daffb766d 100644 --- a/main/file.c +++ b/main/file.c @@ -747,17 +747,13 @@ int ast_closestream(struct ast_filestream *f) if (f->owner) { if (f->fmt->format & AST_FORMAT_AUDIO_MASK) { f->owner->stream = NULL; - if (f->owner->streamid > -1) - ast_sched_del(f->owner->sched, f->owner->streamid); - f->owner->streamid = -1; + AST_SCHED_DEL(f->owner->sched, f->owner->streamid); #ifdef HAVE_ZAPTEL ast_settimeout(f->owner, 0, NULL, NULL); #endif } else { f->owner->vstream = NULL; - if (f->owner->vstreamid > -1) - ast_sched_del(f->owner->sched, f->owner->vstreamid); - f->owner->vstreamid = -1; + AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid); } } /* destroy the translator on exit */ diff --git a/main/rtp.c b/main/rtp.c index d59d29bb7..5671f8a89 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -2374,10 +2374,7 @@ struct ast_rtp *ast_rtp_get_bridged(struct ast_rtp *rtp) void ast_rtp_stop(struct ast_rtp *rtp) { - if (rtp->rtcp && rtp->rtcp->schedid > 0) { - ast_sched_del(rtp->sched, rtp->rtcp->schedid); - rtp->rtcp->schedid = -1; - } + AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid); memset(&rtp->them.sin_addr, 0, sizeof(rtp->them.sin_addr)); memset(&rtp->them.sin_port, 0, sizeof(rtp->them.sin_port)); @@ -2507,8 +2504,7 @@ void ast_rtp_destroy(struct ast_rtp *rtp) if (rtp->s > -1) close(rtp->s); if (rtp->rtcp) { - if (rtp->rtcp->schedid > 0) - ast_sched_del(rtp->sched, rtp->rtcp->schedid); + AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid); close(rtp->rtcp->s); ast_free(rtp->rtcp); rtp->rtcp=NULL; @@ -2734,9 +2730,7 @@ static int ast_rtcp_write_sr(const void *data) if (!rtp->rtcp->them.sin_addr.s_addr) { /* This'll stop rtcp for this rtp session */ ast_verbose("RTCP SR transmission error, rtcp halted\n"); - if (rtp->rtcp->schedid > 0) - ast_sched_del(rtp->sched, rtp->rtcp->schedid); - rtp->rtcp->schedid = -1; + AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid); return 0; } @@ -2793,9 +2787,7 @@ static int ast_rtcp_write_sr(const void *data) res = sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, (struct sockaddr *)&rtp->rtcp->them, sizeof(rtp->rtcp->them)); if (res < 0) { ast_log(LOG_ERROR, "RTCP SR transmission error to %s:%d, rtcp halted %s\n",ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port), strerror(errno)); - if (rtp->rtcp->schedid > 0) - ast_sched_del(rtp->sched, rtp->rtcp->schedid); - rtp->rtcp->schedid = -1; + AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid); return 0; } @@ -2868,9 +2860,7 @@ static int ast_rtcp_write_rr(const void *data) if (!rtp->rtcp->them.sin_addr.s_addr) { ast_log(LOG_ERROR, "RTCP RR transmission error, rtcp halted\n"); - if (rtp->rtcp->schedid > 0) - ast_sched_del(rtp->sched, rtp->rtcp->schedid); - rtp->rtcp->schedid = -1; + AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid); return 0; } @@ -2917,9 +2907,7 @@ static int ast_rtcp_write_rr(const void *data) if (res < 0) { ast_log(LOG_ERROR, "RTCP RR transmission error, rtcp halted: %s\n",strerror(errno)); /* Remove the scheduler */ - if (rtp->rtcp->schedid > 0) - ast_sched_del(rtp->sched, rtp->rtcp->schedid); - rtp->rtcp->schedid = -1; + AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid); return 0; } |