[Telepathy-commits] [telepathy-mission-control/master] Sync the temporary file
Alberto Mardegan
alberto.mardegan at nokia.com
Mon Mar 16 02:52:27 PDT 2009
---
src/mcd-misc.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/mcd-misc.c b/src/mcd-misc.c
index ef91f28..ff70b84 100644
--- a/src/mcd-misc.c
+++ b/src/mcd-misc.c
@@ -26,6 +26,7 @@
#include "mcd-misc.h"
#include <errno.h>
#define __USE_POSIX
+#define __USE_BSD
#include <glib/gstdio.h>
#include <fcntl.h>
#include <stdio.h>
@@ -409,6 +410,24 @@ write_to_temp_file (const gchar *contents,
}
errno = 0;
+ if (fsync (fd) == -1)
+ {
+ save_errno = 0;
+
+ g_set_error (err,
+ G_FILE_ERROR,
+ g_file_error_from_errno (save_errno),
+ "Failed to sync file '%s': fsync() failed: %s",
+ display_name,
+ g_strerror (save_errno));
+
+ fclose (file);
+ g_unlink (tmp_name);
+
+ goto out;
+ }
+
+ errno = 0;
if (fclose (file) == EOF)
{
save_errno = 0;
--
1.5.6.5
More information about the telepathy-commits
mailing list