[asterisk-commits] mmichelson: branch 1.6.1 r173356 - in /branches/1.6.1: ./ main/file.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Feb 4 09:31:26 CST 2009
Author: mmichelson
Date: Wed Feb 4 09:31:26 2009
New Revision: 173356
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=173356
Log:
Merged revisions 173354 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r173354 | mmichelson | 2009-02-04 09:30:12 -0600 (Wed, 04 Feb 2009) | 30 lines
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
........
Modified:
branches/1.6.1/ (props changed)
branches/1.6.1/main/file.c
Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.1/main/file.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.1/main/file.c?view=diff&rev=173356&r1=173355&r2=173356
==============================================================================
--- branches/1.6.1/main/file.c (original)
+++ branches/1.6.1/main/file.c Wed Feb 4 09:31:26 2009
@@ -719,9 +719,14 @@
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) {
More information about the asterisk-commits
mailing list