gedit code break request (fsync)
- From: Paolo Borelli <paolo borelli gmail com>
- To: GNOME Release Team <release-team gnome org>
- Subject: gedit code break request (fsync)
- Date: Fri, 13 Mar 2009 14:19:14 +0100
Hi,
I ask permission to apply the attached patch. It is the gedit
counterpart to the request explained by Alex in
http://mail.gnome.org/archives/gtk-devel-list/2009-March/msg00082.html
In gedit it should be less controversial since we are always writing a
single file, so there are no heavy performance implications.
Ciao,
Paolo
Index: gedit/gedit-local-document-saver.c
===================================================================
--- gedit/gedit-local-document-saver.c (revisione 6949)
+++ gedit/gedit-local-document-saver.c (copia locale)
@@ -234,6 +234,21 @@
} while ((bytes_read != 0) && (ret == TRUE));
+#ifdef HAVE_FSYNC
+ if (ret)
+ {
+ /* Ensure that all the data reaches disk */
+ if (fsync (dfd) != 0)
+ {
+ g_set_error (error,
+ G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ ret = FALSE;
+ }
+ }
+#endif
+
g_free (buffer);
return ret;
Index: gedit/gedit-document-saver.c
===================================================================
--- gedit/gedit-document-saver.c (revisione 6949)
+++ gedit/gedit-document-saver.c (copia locale)
@@ -352,9 +352,13 @@
if (errno == EINTR)
continue;
+ g_set_error (error,
+ G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+
res = FALSE;
-
- break;
+ goto out;
}
to_write -= written;
@@ -383,16 +387,21 @@
}
}
- g_free (contents);
-
- if (!res)
+#ifdef HAVE_FSYNC
+ /* Ensure that all the data reaches disk */
+ if (fsync (fd) != 0)
{
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
"%s", g_strerror (errno));
+ res = FALSE;
}
+#endif
+ out:
+ g_free (contents);
+
return res;
}
Index: configure.ac
===================================================================
--- configure.ac (revisione 6949)
+++ configure.ac (copia locale)
@@ -45,6 +45,8 @@
AC_SYS_LARGEFILE
+AC_CHECK_FUNCS(fsync)
+
dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS -I m4")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]