util: disable cache if we have no build-id and timestamp is zero
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 19 Sep 2018 22:54:32 +0000 (08:54 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 2 Oct 2018 12:07:55 +0000 (22:07 +1000)
Timestamp can be zero for example when Flatpak is used. In this
case just disable the cache rather then segfaulting when
incompatible cache items are loaded.

V2: actually return false when mtime is 0.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_device.c
src/util/disk_cache.h

index 3e0d75bb1b6653ed2753e750fd37d96a98376a1b..429d47325a3d12883b86188c74233ebe032b57b4 100644 (file)
@@ -61,10 +61,6 @@ radv_get_build_id(void *ptr, struct mesa_sha1 *ctx)
        } else
 #endif
        if (disk_cache_get_function_timestamp(ptr, &timestamp)) {
-               if (!timestamp) {
-                       fprintf(stderr, "radv: The provided filesystem timestamp for the cache is bogus!\n");
-               }
-
                _mesa_sha1_update(ctx, &timestamp, sizeof(timestamp));
        } else
                return false;
index 50bd9f41ac4b3097b2af0318f23c936b4d615859..c8685a53ed3024951cf618dd5428c8e8fbe3bb5d 100644 (file)
@@ -26,6 +26,7 @@
 
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
+#include <stdio.h>
 #endif
 #include <assert.h>
 #include <stdint.h>
@@ -100,7 +101,15 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
    if (stat(info.dli_fname, &st)) {
       return false;
    }
+
+   if (!st.st_mtime) {
+      fprintf(stderr, "Mesa: The provided filesystem timestamp for the cache "
+              "is bogus! Disabling On-disk cache.\n");
+      return false;
+   }
+
    *timestamp = st.st_mtime;
+
    return true;
 }
 #endif