]> gitweb.ps.run Git - ps-cgit/blobdiff - cache.c
cache: flush stdio before restoring FDs
[ps-cgit] / cache.c
diff --git a/cache.c b/cache.c
index 6736a017b2fce59608dac7318cbafac518045c3c..2ccdc4ebcefd44dc7a4a34d5455356da3fe9ee3e 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -224,6 +224,12 @@ static int fill_slot(struct cache_slot *slot)
        /* Generate cache content */
        slot->fn();
 
+       /* Make sure any buffered data is flushed to the file */
+       if (fflush(stdout)) {
+               close(tmp);
+               return errno;
+       }
+
        /* update stat info */
        if (fstat(slot->lock_fd, &slot->cache_st)) {
                close(tmp);