Mesa (staging/19.1): util: Workaround lack of flock on Solaris
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 16 15:39:15 UTC 2019
Module: Mesa
Branch: staging/19.1
Commit: 13120904e463868e4a6eb51644c5e3a1a2c732e4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=13120904e463868e4a6eb51644c5e3a1a2c732e4
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date: Fri Apr 21 21:57:50 2017 -0700
util: Workaround lack of flock on Solaris
v2: Replace autoconf check for flock() with meson check
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
Acked-by: Eric Engestrom <eric.engestrom at intel.com>
(cherry picked from commit b3028a9fb8110fd37f60e9d66dad3cde6e7b062b)
[Juan A. Suarez: resolve trivial conflicts]
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
Conflicts:
meson.build
---
meson.build | 2 +-
src/util/disk_cache.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index abd27142b03..3bb97e01e2a 100644
--- a/meson.build
+++ b/meson.build
@@ -1057,7 +1057,7 @@ foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h'
endif
endforeach
-foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create']
+foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create', 'flock']
if cc.has_function(f)
pre_args += '-DHAVE_ at 0@'.format(f.to_upper())
endif
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index bc3becfe535..9bc19950636 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -902,7 +902,17 @@ cache_put(void *job, int thread_index)
* open with the flock held. So just let that file be responsible
* for writing the file.
*/
+#ifdef HAVE_FLOCK
err = flock(fd, LOCK_EX | LOCK_NB);
+#else
+ struct flock lock = {
+ .l_start = 0,
+ .l_len = 0, /* entire file */
+ .l_type = F_WRLCK,
+ .l_whence = SEEK_SET
+ };
+ err = fcntl(fd, F_SETLK, &lock);
+#endif
if (err == -1)
goto done;
More information about the mesa-commit
mailing list