diff options
author | seanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b> | 2011-01-26 01:26:26 +0000 |
---|---|---|
committer | seanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b> | 2011-01-26 01:26:26 +0000 |
commit | d26f7f8fafeb0da74a4540c60ad480a76005e6b9 (patch) | |
tree | 9d4a5c13fa3098d1673a81ab5ed33cc926130eeb /main | |
parent | 3cd924c71ea896dd28f86e03ef6f7794ea514323 (diff) |
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
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@304097 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/file.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/main/file.c b/main/file.c index 205daf482..6f0cdd446 100644 --- a/main/file.c +++ b/main/file.c @@ -1111,6 +1111,11 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con 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 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con } 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)); |