From 96aa27910a19d8cd38373b57abdc21448838192d Mon Sep 17 00:00:00 2001 From: Peter Seiderer Date: Thu, 12 Dec 2019 11:37:56 +0100 Subject: [PATCH] registry: handle fsync interrupted by signal (EINTR) According to [1] EINTR is a possible errno for fsync(), so handle it as all other EINTR (do/while(errno == EINTR)). Signed-off-by: Peter Seiderer --- gst/gstregistrybinary.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 2e6451b821..7c47958bef 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -241,9 +241,16 @@ gst_registry_binary_cache_write (BinaryRegistryCache * cache, static gboolean gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success) { + gint fsync_ret; + /* only fsync if we're actually going to use and rename the file below */ - if (success && fsync (cache->cache_fd) < 0) - goto fsync_failed; + if (success) { + do { + fsync_ret = fsync (cache->cache_fd); + } while (fsync_ret < 0 && errno == EINTR); + if (fsync_ret) + goto fsync_failed; + } if (close (cache->cache_fd) < 0) goto close_failed;