This helps prevent filesystem/data inconsistencies in certain
circumstances on certain filesystems (like ext4, xfs, ubifs).
Also see bug #562976.
gst_registry_binary_cache_finish (GstRegistry * registry,
BinaryRegistryCache * cache, gboolean success)
{
+ /* only fsync if we're actually going to use and rename the file below */
+ if (success && fsync (registry->cache_file) < 0)
+ goto fsync_failed;
+
if (close (registry->cache_file) < 0)
goto close_failed;
GST_INFO ("Wrote binary registry cache");
return TRUE;
+/* ERRORS */
fail_after_close:
{
g_unlink (cache->tmp_location);
g_free (cache);
return FALSE;
}
+fsync_failed:
+ {
+ GST_ERROR ("fsync() failed: %s", g_strerror (errno));
+ goto fail_after_close;
+ }
close_failed:
{
GST_ERROR ("close() failed: %s", g_strerror (errno));
if (!gst_registry_save (registry, "</GST-PluginRegistry>\n"))
goto fail;
+ if (fsync (registry->cache_file) < 0)
+ goto fsync_failed;
+
/* check return value of close(), write errors may only get reported here */
if (close (registry->cache_file) < 0)
goto close_failed;
g_free (tmp_location);
return FALSE;
}
+fsync_failed:
+ {
+ GST_ERROR ("fsync() failed: %s", g_strerror (errno));
+ goto fail_after_close;
+ }
close_failed:
{
GST_ERROR ("close() failed: %s", g_strerror (errno));