aboutsummaryrefslogtreecommitdiffstats
path: root/main/rtp.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-27 22:35:29 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-27 22:35:29 +0000
commitc83caa1ae0033f53e8e51f98415a48f69fb0b349 (patch)
tree7b27e35fa085d171969d24fcc34ee5ba0350fead /main/rtp.c
parent76bbd4b67a62edd656285e38f7e204a000d6b091 (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: http://svn.digium.com/svn/asterisk/trunk@100488 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/rtp.c')
-rw-r--r--main/rtp.c24
1 files changed, 6 insertions, 18 deletions
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;
}