summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2017-04-21 21:57:50 -0700
committerJuan A. Suarez Romero <jasuarez@igalia.com>2019-10-16 14:52:59 +0000
commit13120904e463868e4a6eb51644c5e3a1a2c732e4 (patch)
treedb758662d4a2044cd693543d3bad2468e0af5d16
parent740b0e9dc7597070a345cbcea57421f6894041fb (diff)
downloadmesa-13120904e463868e4a6eb51644c5e3a1a2c732e4.tar.gz
util: Workaround lack of flock on Solaris
v2: Replace autoconf check for flock() with meson check Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Eric Engestrom <eric.engestrom@intel.com> (cherry picked from commit b3028a9fb8110fd37f60e9d66dad3cde6e7b062b) [Juan A. Suarez: resolve trivial conflicts] Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Conflicts: meson.build
-rw-r--r--meson.build2
-rw-r--r--src/util/disk_cache.c10
2 files changed, 11 insertions, 1 deletions
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_@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;