aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-03-17 06:50:27 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-03-17 06:50:27 +0000
commit56bc524ac9e7eb53b0f4fc7b49b1ebe10a327180 (patch)
tree80a34cb7bcaa54cced64c5db8db4cb05693b2af2 /libsylph
parent3ad4efad565998dda3a31d9d4d2a4dceda980aac (diff)
do fflush() and fsync() before fclose() when writing configuration files.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2121 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/prefs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libsylph/prefs.c b/libsylph/prefs.c
index d2e01d2a..07078d52 100644
--- a/libsylph/prefs.c
+++ b/libsylph/prefs.c
@@ -373,6 +373,9 @@ gint prefs_file_close(PrefFile *pfile)
{
PrefFilePrivate *priv = (PrefFilePrivate *)pfile;
FILE *fp;
+#if HAVE_FSYNC
+ gint fd;
+#endif
gchar *path;
gchar *tmppath;
gchar *bakpath = NULL;
@@ -387,6 +390,16 @@ gint prefs_file_close(PrefFile *pfile)
g_free(pfile);
tmppath = g_strconcat(path, ".tmp", NULL);
+ if (fflush(fp) == EOF) {
+ FILE_OP_ERROR(tmppath, "fflush");
+ fclose(fp);
+ ret = -1;
+ goto finish;
+ }
+#if HAVE_FSYNC
+ if ((fd = fileno(fp)) >= 0)
+ fsync(fd);
+#endif
if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmppath, "fclose");
ret = -1;