There is exactly one flock in mesa and it caused mesa not to build
on windows when shader cache was enabled.

It should be possible to revert 9f8dc3bf03ec825bae7041858dda6ca2e9a34363
"utils: build sha1/disk cache only with Android/Autoconf" currently
guarding the offending code with ENABLE_SHADER_CACHE

This would allow shader cache to work on windows I think.
I dont have a test system with windows though.

This builds on linux and is tested with Deus Ex:MD and Metro 2033 Redux
both with cold shader cache.

Really
Fixes: d1efa09d342bff3e5def2978a0bef748d74f9c82

v2: make the patch ridiculously simple (Jan Vesely) needs testing though

CC: Tapani Pälli <tapani.pa...@intel.com>
CC: "Marek Olšák" <mar...@gmail.com>
CC: Emil Velikov <emil.l.veli...@gmail.com>
CC: Timothy Arceri <tarc...@itsqueeze.com>
CC: Samuel Pitoiset <samuel.pitoi...@gmail.com>
CC: Jan Vesely <jan.ves...@rutgers.edu>
---
This enables the patch
[PATCH 1/3] mesa/main/shaderapi: Use generate_sha1() unconditionally

 src/util/disk_cache.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 4a762eff20..35847af6a6 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <sys/file.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
@@ -876,7 +875,7 @@ cache_put(void *job, int thread_index)
    if (asprintf(&filename_tmp, "%s.tmp", filename) == -1)
       goto done;
 
-   fd = open(filename_tmp, O_WRONLY | O_CLOEXEC | O_CREAT, 0644);
+   fd = open(filename_tmp, O_WRONLY | O_CLOEXEC | O_CREAT | O_EXCL, 0644);
 
    /* Make the two-character subdirectory within the cache as needed. */
    if (fd == -1) {
@@ -890,16 +889,7 @@ cache_put(void *job, int thread_index)
          goto done;
    }
 
-   /* With the temporary file open, we take an exclusive flock on
-    * it. If the flock fails, then another process still has the file
-    * open with the flock held. So just let that file be responsible
-    * for writing the file.
-    */
-   err = flock(fd, LOCK_EX | LOCK_NB);
-   if (err == -1)
-      goto done;
-
-   /* Now that we have the lock on the open temporary file, we can
+   /* Now that we have the open temporary file, we can
     * check to see if the destination file already exists. If so,
     * another process won the race between when we saw that the file
     * didn't exist and now. In this case, we don't do anything more,
-- 
2.14.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to