changeset 21177:abc909eeb580

jtb indirectly points out that we need a fflush() before the fsync(), which I forgot.
author Ethan Blanton <elb@pidgin.im>
date Thu, 08 Nov 2007 23:47:22 +0000
parents 726f91be55ed
children 6972d47286c4
files libpurple/util.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Thu Nov 08 19:50:22 2007 +0000
+++ b/libpurple/util.c	Thu Nov 08 23:47:22 2007 +0000
@@ -2602,6 +2602,13 @@
 	/* Apparently XFS (and possibly other filesystems) do not
 	 * guarantee that file data is flushed before file metadata,
 	 * so this procedure is insufficient without some flushage. */
+	if (fflush(file) < 0) {
+		purple_debug_error("util", "Error flushing %s: %s\n",
+				   filename_temp, g_strerror(errno));
+		g_free(filename_temp);
+		fclose(file);
+		return FALSE;
+	}
 	if (fsync(fileno(file)) < 0) {
 		purple_debug_error("util", "Error syncing file contents for %s: %s\n",
 				   filename_temp, g_strerror(errno));