aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-03-17 08:56:27 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-03-17 08:56:27 +0000
commitd0240722220985b4ca879c6caa1ca927d5309588 (patch)
treeb0edcf8906ba08caa3f5000f9507de01acc3c2c4
parent56bc524ac9e7eb53b0f4fc7b49b1ebe10a327180 (diff)
abort if fsync() fails.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2122 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog4
-rw-r--r--ChangeLog.ja5
-rw-r--r--libsylph/prefs.c10
3 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 02d7280b..df91aa77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2008-03-17
+ * libsylph/prefs.c: prefs_file_close(): abort if fsync() fails.
+
+2008-03-17
+
* libsylph/prefs.c
configure.in: prefs_file_close(): do fflush() and fsync() before
fclose() to lessen the possibility of data loss.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index f439ea64..32cc7d3a 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,10 @@
2008-03-17
+ * libsylph/prefs.c: prefs_file_close(): fsync() が失敗したら処理を
+ 中断するようにした。
+
+2008-03-17
+
* libsylph/prefs.c
configure.in: prefs_file_close(): fclose() の前に fflush() と
fsync() を行うようにした(データロスの可能性を減らすため)。
diff --git a/libsylph/prefs.c b/libsylph/prefs.c
index 07078d52..56a2eda6 100644
--- a/libsylph/prefs.c
+++ b/libsylph/prefs.c
@@ -397,8 +397,14 @@ gint prefs_file_close(PrefFile *pfile)
goto finish;
}
#if HAVE_FSYNC
- if ((fd = fileno(fp)) >= 0)
- fsync(fd);
+ if ((fd = fileno(fp)) >= 0) {
+ if (fsync(fd) < 0) {
+ FILE_OP_ERROR(tmppath, "fsync");
+ fclose(fp);
+ ret = -1;
+ goto finish;
+ }
+ }
#endif
if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmppath, "fclose");