[asterisk-commits] seanbright: branch 1.8 r304097 - in /branches/1.8: ./ main/file.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 25 19:26:31 CST 2011


Author: seanbright
Date: Tue Jan 25 19:26:26 2011
New Revision: 304097

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=304097
Log:
Merged revisions 304096 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
  r304096 | seanbright | 2011-01-25 20:24:58 -0500 (Tue, 25 Jan 2011) | 12 lines
  
  Per the man page, setvbuf() must be called before any other operation on an open file.
  
  We use setvbuf() to associate a buffer with a stream, but we have already written
  to the open file.  This works (by chance) on Linux, but fails on other platforms,
  such as OpenSolaris.
  
  (closes issue #16610)
  Reported by: bklang
  Patches:
        setvbuf.patch uploaded by crjw (license 963)
  Tested by: bklang, asgaroth, efutch
........

Modified:
    branches/1.8/   (props changed)
    branches/1.8/main/file.c

Propchange: branches/1.8/
------------------------------------------------------------------------------
Binary property 'branch-1.6.2-merged' - no diff available.

Modified: branches/1.8/main/file.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/file.c?view=diff&rev=304097&r1=304096&r2=304097
==============================================================================
--- branches/1.8/main/file.c (original)
+++ branches/1.8/main/file.c Tue Jan 25 19:26:26 2011
@@ -1111,6 +1111,11 @@
 		if (fd > -1) {
 			errno = 0;
 			fs = get_filestream(f, bfile);
+			if (fs) {
+				if ((fs->write_buffer = ast_malloc(32768))) {
+					setvbuf(fs->f, fs->write_buffer, _IOFBF, 32768);
+				}
+			}
 			if (!fs || rewrite_wrapper(fs, comment)) {
 				ast_log(LOG_WARNING, "Unable to rewrite %s\n", fn);
 				close(fd);
@@ -1137,11 +1142,6 @@
 			}
 			fs->vfs = NULL;
 			/* If truncated, we'll be at the beginning; if not truncated, then append */
-
-			if ((fs->write_buffer = ast_malloc(32768))){
-				setvbuf(fs->f, fs->write_buffer, _IOFBF, 32768);
-			}
-
 			f->seek(fs, 0, SEEK_END);
 		} else if (errno != EEXIST) {
 			ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno));




More information about the asterisk-commits mailing list