util/disk_cache: close a previously opened handle in disk_cache_put (v2)
[mesa.git] / src / util / disk_cache.c
index 428787820e3d722d63d3277dc7cc75577ae7d9c2..80dc7881d591cbef46b1a39fe782f2f447b0e8a2 100644 (file)
@@ -612,19 +612,18 @@ disk_cache_put(struct disk_cache *cache,
 
    p_atomic_add(cache->size, size);
 
+ done:
+   if (fd_final != -1)
+      close(fd_final);
    /* This close finally releases the flock, (now that the final dile
     * has been renamed into place and the size has been added).
     */
-   close(fd);
-   fd = -1;
-
- done:
+   if (fd != -1)
+      close(fd);
    if (filename_tmp)
       ralloc_free(filename_tmp);
    if (filename)
       ralloc_free(filename);
-   if (fd != -1)
-      close(fd);
 }
 
 void *