Skip to content
Snippets Groups Projects
Commit bd244342 authored by Mark Michelson's avatar Mark Michelson
Browse files

Fix a problem where file playback would cause fds to remain open forever

The problem came from the fact that a frame read from a format interpreter
was not freed. Adding a call to ast_frfree fixed this. The explanation for
why this caused the problem is a bit complex, but here goes:

There was a problem in all versions of Asterisk where the embedded frame
of a filestream structure was referenced after the filestream was freed. This
was fixed by adding reference counting to the filestream structure. The refcount
would increase every time that a filestream's frame pointer was pointing to an
actual frame of data. When the frame was freed, the refcount would decrease. Once
the refcount reached 0, the filestream was freed, and as part of the operation,
the open files were closed as well.

Thus it becomes more clear why a missing ast_frfree would cause a reference leak
and cause the files to not be closed. You may ask then if there was a frame leak
before this patch. The answer to that is actually no! The filestream code was
"smart" enough to know that since the frame we received came from a format interpreter,
the frame had no malloced data and thus didn't need to be freed. Now, however, there
is cleanup that needs to be done when we finish with the frame, so we do need to
call ast_frfree on the frame to be sure that the refcount for the filestream is
decremented appropriately.

(closes issue #14384)
Reported by: fiddur
Patches:
      14384.patch uploaded by putnopvut (license 60)
Tested by: fiddur, putnopvut



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@173354 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent f90021fd
No related branches found
No related tags found
No related merge requests found
......@@ -719,9 +719,14 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
ao2_ref(s, +1);
}
if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
if (fr)
if (fr) {
ast_log(LOG_WARNING, "Failed to write frame\n");
ast_frfree(fr);
}
goto return_failure;
}
if (fr) {
ast_frfree(fr);
}
}
if (whennext != s->lasttimeout) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment