[asterisk-commits] russell: branch 11 r380211 - in /branches/11: ./ main/file.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jan 27 19:57:29 CST 2013
Author: russell
Date: Sun Jan 27 19:57:26 2013
New Revision: 380211
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380211
Log:
Change cleanup ordering in filestream destructor.
This patch came about due to a problem observed where wav files had an
empty header. The header is supposed to be updated in wav_close(). It
turns out that this was broken when the cache_record_files option from
asterisk.conf was enabled. The cleanup code was moving the file to its
final destination *before* running the close() method of the file
destructor, so the header didn't get updated.
Another problem here is that the move was being done before actually
closing the FILE *.
Finally, the last bug fixed here is that I noticed that wav_close()
checks for stream->filename to be non-NULL. In the previous cleanup
order, it's checking a pointer to freed memory. This doesn't actually
cause anything to break, but it's treading on dangerous waters. Now the
free() of stream->filename is happening after the format module's
close() method gets called, so it's safer.
Review: https://reviewboard.asterisk.org/r/2286/
........
Merged revisions 380210 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/11/ (props changed)
branches/11/main/file.c
Propchange: branches/11/
------------------------------------------------------------------------------
--- branch-1.8-merged (original)
+++ branch-1.8-merged Sun Jan 27 19:57:26 2013
@@ -1,1 +1,1 @@
-/branches/1.8:1-378147,378164,378356,378375,378427,378455-378456,378486,378514,378554,378591,378733,378776,378933,378967,379001,379145,379178,379226,379276,379310,379342,379392,379547,379608,379718,379825,379885,379963
+/branches/1.8:1-378147,378164,378356,378375,378427,378455-378456,378486,378514,378554,378591,378733,378776,378933,378967,379001,379145,379178,379226,379276,379310,379342,379392,379547,379608,379718,379825,379885,379963,380210
Modified: branches/11/main/file.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/file.c?view=diff&rev=380211&r1=380210&r2=380211
==============================================================================
--- branches/11/main/file.c (original)
+++ branches/11/main/file.c Sun Jan 27 19:57:26 2013
@@ -329,6 +329,15 @@
if (f->trans)
ast_translator_free_path(f->trans);
+ if (f->fmt->close) {
+ void (*closefn)(struct ast_filestream *) = f->fmt->close;
+ closefn(f);
+ }
+
+ if (f->f) {
+ fclose(f->f);
+ }
+
if (f->realfilename && f->filename) {
pid = ast_safe_fork(0);
if (!pid) {
@@ -345,12 +354,6 @@
free(f->filename);
if (f->realfilename)
free(f->realfilename);
- if (f->fmt->close) {
- void (*closefn)(struct ast_filestream *) = f->fmt->close;
- closefn(f);
- }
- if (f->f)
- fclose(f->f);
if (f->vfs)
ast_closestream(f->vfs);
if (f->write_buffer) {
More information about the asterisk-commits
mailing list