[asterisk-commits] mjordan: trunk r326210 - in /trunk: ./ main/file.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 5 08:38:41 CDT 2011
Author: mjordan
Date: Tue Jul 5 08:38:37 2011
New Revision: 326210
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=326210
Log:
Merged revisions 326209 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r326209 | mjordan | 2011-07-05 08:23:57 -0500 (Tue, 05 Jul 2011) | 7 lines
Updated filestream destructor to block until move is complete when cache is used
When a cache directory is used, the process is forked and a mv command is executed to move the temporary file to the permanent location. This caused issues with voicemail, where a race condition occurred when the parent expected the file to be in the permanent location prior to the mv command completing. The parent process is now blocked until the mv command completes.
(closes issue ASTERISK-17724)
Reported by: Adiren P.
Tested by: mjordan
........
Modified:
trunk/ (props changed)
trunk/main/file.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: trunk/main/file.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/file.c?view=diff&rev=326210&r1=326209&r2=326210
==============================================================================
--- trunk/main/file.c (original)
+++ trunk/main/file.c Tue Jul 5 08:38:37 2011
@@ -29,6 +29,7 @@
#include <dirent.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <math.h>
#include "asterisk/_private.h" /* declare ast_file_init() */
@@ -289,6 +290,8 @@
static void filestream_destructor(void *arg)
{
struct ast_filestream *f = arg;
+ int status;
+ int pid = -1;
/* Stop a running stream if there is one */
if (f->owner) {
@@ -306,8 +309,14 @@
ast_translator_free_path(f->trans);
if (f->realfilename && f->filename) {
- if (ast_safe_fork(0) == 0) {
+ pid = ast_safe_fork(0);
+ if (!pid) {
execl("/bin/mv", "mv", "-f", f->filename, f->realfilename, SENTINEL);
+ _exit(1);
+ }
+ else if (pid > 0) {
+ /* Block the parent until the move is complete.*/
+ waitpid(pid, &status, 0);
}
}
More information about the asterisk-commits
mailing list