summaryrefslogtreecommitdiff
path: root/main/abstract_jb.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-01-15 23:31:53 +0000
committerRussell Bryant <russell@russellbryant.com>2008-01-15 23:31:53 +0000
commit4fb04cb58a15aafd7cf4be6d042bc0cccdbbefe9 (patch)
tree1aab12c7f6e5db8c4e07bc805598fb65bf9babf1 /main/abstract_jb.c
parent9a76fbf9c2bd2ea81d68434f45fbf219929ea662 (diff)
Merged revisions 98943 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r98943 | russell | 2008-01-15 17:26:52 -0600 (Tue, 15 Jan 2008) | 25 lines Commit a fix for some memory access errors pointed out by the valgrind2.txt output on issue #11698. The issue here is that it is possible for an instance of a translator to get destroyed while the frame allocated as a part of the translator is still being processed. Specifically, this is possible anywhere between a call to ast_read() and ast_frame_free(), which is _a lot_ of places in the code. The reason this happens is that the channel might get masqueraded during this time. During a masquerade, existing translation paths get destroyed. So, this patch fixes the issue in an API and ABI compatible way. (This one is for you, paravoid!) It changes an int in ast_frame to be used as flag bits. The 1 bit is still used to indicate that the frame contains timing information. Also, a second flag has been added to indicate that the frame came from a translator. When a frame with this flag gets released and has this flag, a function is called in translate.c to let it know that this frame is doing being processed. At this point, the flag gets cleared. Also, if the translator was requested to be destroyed while its internal frame still had this flag set, its destruction has been deffered until it finds out that the frame is no longer being processed. Admittedly, this feels like a hack. But, it does fix the issue, and I was not able to think of a better solution ... ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98944 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/abstract_jb.c')
-rw-r--r--main/abstract_jb.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index afc6bd182..4f464796d 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -312,10 +312,10 @@ int ast_jb_put(struct ast_channel *chan, struct ast_frame *f)
}
/* We consider an enabled jitterbuffer should receive frames with valid timing info. */
- if (!f->has_timing_info || f->len < 2 || f->ts < 0) {
+ if (!ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO) || f->len < 2 || f->ts < 0) {
ast_log(LOG_WARNING, "%s received frame with invalid timing info: "
"has_timing_info=%d, len=%ld, ts=%ld, src=%s\n",
- chan->name, f->has_timing_info, f->len, f->ts, f->src);
+ chan->name, ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO), f->len, f->ts, f->src);
return -1;
}