From: <tp...@ke...> - 2007-12-16 18:29:41
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: tpm Date: Sun Dec 16 2007 18:29:40 UTC Log message: * gst/gstregistrybinary.c: (gst_registry_binary_write_cache): Use g_remove() and g_rename(). Check result of g_rename(), and don't leak the open file descriptor if we error out when writing. * gst/gstregistryxml.c: (load_plugin), (gst_registry_xml_write_cache): Must check the return value of close() after writing out the new registry file. Sometimes write problems such as out-of-diskspace are only reported when the file is closed and not already during the write. This may have caused partial/broken registry files in some rare circumstances. Should fix #503675. Modified files: . : ChangeLog gst : gstregistrybinary.c gstregistryxml.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.3581&r2=1.3582 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstregistrybinary.c.diff?r1=1.16&r2=1.17 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstregistryxml.c.diff?r1=1.38&r2=1.39 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.3581 retrieving revision 1.3582 diff -u -d -r1.3581 -r1.3582 --- ChangeLog 16 Dec 2007 17:37:09 -0000 1.3581 +++ ChangeLog 16 Dec 2007 18:29:23 -0000 1.3582 @@ -1,3 +1,16 @@ +2007-12-16 Tim-Philipp Müller <tim at centricular dot net> + + * gst/gstregistrybinary.c: (gst_registry_binary_write_cache): + Use g_remove() and g_rename(). Check result of g_rename(), and + don't leak the open file descriptor if we error out when writing. + * gst/gstregistryxml.c: (load_plugin), (gst_registry_xml_write_cache): + Must check the return value of close() after writing out the new + registry file. Sometimes write problems such as out-of-diskspace + are only reported when the file is closed and not already during + the write. This may have caused partial/broken registry files in + some rare circumstances. Should fix #503675. 2007-12-16 Edward Hervey <edw...@co...> * docs/gst/.cvsignore: Index: gstregistrybinary.c RCS file: /cvs/gstreamer/gstreamer/gst/gstregistrybinary.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- gstregistrybinary.c 13 Oct 2007 17:20:09 -0000 1.16 +++ gstregistrybinary.c 16 Dec 2007 18:29:25 -0000 1.17 @@ -544,16 +544,17 @@ } g_list_free (to_write); - if (close (registry->cache_file) < 0) { - GST_DEBUG ("Can't close registry file : %s", g_strerror (errno)); - goto fail; - } + if (close (registry->cache_file) < 0) + goto close_failed; if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) { #ifdef WIN32 - remove (location); + g_remove (location); #endif - rename (tmp_location, location); + if (g_rename (tmp_location, location) < 0) + goto rename_failed; + } else { + /* FIXME: shouldn't we return FALSE here? */ g_free (tmp_location); @@ -562,8 +563,26 @@ /* Errors */ fail: - g_free (tmp_location); - return FALSE; + { + (void) close (registry->cache_file); + /* fall through */ + } +fail_after_close: + g_remove (tmp_location); + g_free (tmp_location); + return FALSE; +close_failed: + GST_ERROR ("close() failed: %s", g_strerror (errno)); + goto fail_after_close; +rename_failed: + GST_ERROR ("g_rename() failed: %s", g_strerror (errno)); } Index: gstregistryxml.c RCS file: /cvs/gstreamer/gstreamer/gst/gstregistryxml.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- gstregistryxml.c 13 Oct 2007 17:20:09 -0000 1.38 +++ gstregistryxml.c 16 Dec 2007 18:29:25 -0000 1.39 @@ -916,22 +916,44 @@ if (!gst_registry_save (registry, "</GST-PluginRegistry>\n")) goto fail; - close (registry->cache_file); + /* check return value of close(), write errors may only get reported here */ g_remove (location); - g_rename (tmp_location, location); - + GST_INFO ("Wrote XML registry cache"); return TRUE; +/* ERRORS */ |