aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/disk_cache.c
diff options
context:
space:
mode:
authorAlan Coopersmith <[email protected]>2017-04-21 21:57:50 -0700
committerEric Engestrom <[email protected]>2019-10-16 13:45:57 +0100
commitb3028a9fb8110fd37f60e9d66dad3cde6e7b062b (patch)
tree357c26fd3de0e90f9d917e6700bc00a15f4041d7 /src/util/disk_cache.c
parenta56c3e3a470eb8f13d11ca0aad5b5934de54ca1c (diff)
util: Workaround lack of flock on Solaris
v2: Replace autoconf check for flock() with meson check Signed-off-by: Alan Coopersmith <[email protected]> Acked-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/util/disk_cache.c')
-rw-r--r--src/util/disk_cache.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 9272e9c5471..77af64ed3b0 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -907,7 +907,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;