util: import sha1 implementation from OpenBSD
[mesa.git] / src / util / disk_cache.c
index 428787820e3d722d63d3277dc7cc75577ae7d9c2..76bdfe8e8b629abc62b6bd45c5ba9220c6a71566 100644 (file)
@@ -21,8 +21,6 @@
  * IN THE SOFTWARE.
  */
 
-#ifdef ENABLE_SHADER_CACHE
-
 #include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
@@ -612,19 +610,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 *
@@ -708,5 +705,3 @@ disk_cache_has_key(struct disk_cache *cache, cache_key key)
 
    return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
 }
-
-#endif