aboutsummaryrefslogtreecommitdiffstats
path: root/main/file.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-04 15:30:54 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-04 15:30:54 +0000
commit53accad5e4c64813cdc69276470d63dab4c1baf8 (patch)
tree91d7afde99dc41cd9c4d4902ddef562b8cff9c79 /main/file.c
parentb8561c6bafe514182f41cb1b6c6ef117723278a6 (diff)
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 ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@173355 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/file.c')
-rw-r--r--main/file.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/file.c b/main/file.c
index fae857ad9..736ab7dfe 100644
--- a/main/file.c
+++ b/main/file.c
@@ -714,9 +714,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) {