From 7296f66a5325a377b18db754b66dba78d41ee707 Mon Sep 17 00:00:00 2001 From: Rex Dieter Date: Wed, 21 May 2014 16:40:21 -0500 Subject: [PATCH] PKGSYSTEM_ENABLE_FSYNC env var opt-in to fdatasync Recent fdatasync() support in update-mime-database results in large slowdown (x40 or more slower in some cases), and it's unclear the safety benefits outweigh this cost. In the meantime, make this feature opt-in via environment variable PKGSYSTEM_ENABLE_FSYNC Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70366 --- update-mime-database.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/update-mime-database.c b/update-mime-database.c index c043606..09c1320 100644 --- a/update-mime-database.c +++ b/update-mime-database.c @@ -951,21 +951,23 @@ static gboolean atomic_update(const gchar *pathname, GError **error) new_name = g_strndup(pathname, len - 4); #ifdef HAVE_FDATASYNC - fd = open(pathname, O_RDWR); - if (fd == -1) - { - set_error_from_errno(error); - goto out; - } - if (fdatasync(fd) == -1) - { - set_error_from_errno(error); - goto out; - } - if (close(fd) == -1) - { - set_error_from_errno(error); - goto out; + if (g_getenv ("PKGSYSTEM_ENABLE_FSYNC")) { + fd = open(pathname, O_RDWR); + if (fd == -1) + { + set_error_from_errno(error); + goto out; + } + if (fdatasync(fd) == -1) + { + set_error_from_errno(error); + goto out; + } + if (close(fd) == -1) + { + set_error_from_errno(error); + goto out; + } } #endif -- 1.9.0