mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
registrybinary: Also call fclose() if fflush()/fsync() failed
Otherwise we would be leaking the file in error cases. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/465>
This commit is contained in:
parent
0d1fe824e2
commit
a3c7e1c9b9
1 changed files with 12 additions and 6 deletions
|
@ -257,6 +257,7 @@ gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success)
|
||||||
/* flush the file and make sure the OS's buffer has been written to disk */
|
/* flush the file and make sure the OS's buffer has been written to disk */
|
||||||
gint fflush_ret, fsync_ret;
|
gint fflush_ret, fsync_ret;
|
||||||
int file_fd;
|
int file_fd;
|
||||||
|
|
||||||
file_fd = fileno (cache->cache_file);
|
file_fd = fileno (cache->cache_file);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -297,6 +298,11 @@ gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
fail_before_fclose:
|
||||||
|
{
|
||||||
|
fclose (cache->cache_file);
|
||||||
|
}
|
||||||
|
/* fall through */
|
||||||
fail_after_fclose:
|
fail_after_fclose:
|
||||||
{
|
{
|
||||||
g_unlink (cache->tmp_location);
|
g_unlink (cache->tmp_location);
|
||||||
|
@ -307,14 +313,14 @@ fail_after_fclose:
|
||||||
fflush_failed:
|
fflush_failed:
|
||||||
{
|
{
|
||||||
GST_ERROR ("fflush() failed: %s", g_strerror (errno));
|
GST_ERROR ("fflush() failed: %s", g_strerror (errno));
|
||||||
goto fail_after_fclose;
|
goto fail_before_fclose;
|
||||||
}
|
|
||||||
fclose_failed:
|
|
||||||
{
|
|
||||||
GST_ERROR ("fsync() failed: %s", g_strerror (errno));
|
|
||||||
goto fail_after_fclose;
|
|
||||||
}
|
}
|
||||||
fsync_failed:
|
fsync_failed:
|
||||||
|
{
|
||||||
|
GST_ERROR ("fsync() failed: %s", g_strerror (errno));
|
||||||
|
goto fail_before_fclose;
|
||||||
|
}
|
||||||
|
fclose_failed:
|
||||||
{
|
{
|
||||||
GST_ERROR ("fclose() failed: %s", g_strerror (errno));
|
GST_ERROR ("fclose() failed: %s", g_strerror (errno));
|
||||||
goto fail_after_fclose;
|
goto fail_after_fclose;
|
||||||
|
|
Loading…
Reference in a new issue