aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja7
-rw-r--r--configure.in2
-rw-r--r--libsylph/prefs.c13
4 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bbfb70d5..02d7280b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-17
+
+ * libsylph/prefs.c
+ configure.in: prefs_file_close(): do fflush() and fsync() before
+ fclose() to lessen the possibility of data loss.
+
2008-03-16
* libsylph/utils.[ch]
diff --git a/ChangeLog.ja b/ChangeLog.ja
index aed72dd0..f439ea64 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,4 +1,11 @@
+2008-03-17
+
+ * libsylph/prefs.c
+ configure.in: prefs_file_close(): fclose() の前に fflush() と
+ fsync() を行うようにした(データロスの可能性を減らすため)。
+
2008-03-16
+
* libsylph/utils.[ch]
libsylph/mh.c: g_link(): Unix で無限ループに陥るバグを修正。
g_link を syl_link に名称変更。
diff --git a/configure.in b/configure.in
index 6b4db039..be4608d5 100644
--- a/configure.in
+++ b/configure.in
@@ -409,7 +409,7 @@ dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(gethostname mkdir mktime socket strstr strchr \
uname flock lockf inet_aton inet_addr \
- fchmod truncate getuid regcomp mlock)
+ fchmod truncate getuid regcomp mlock fsync)
AC_OUTPUT([
Makefile
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;