Index: runtime/bin/file_macos.cc |
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc |
index 941d419352b64e904631ada3b4041d1942d37e05..a43b14eaada0245797ae855c2abde869b97e682c 100644 |
--- a/runtime/bin/file_macos.cc |
+++ b/runtime/bin/file_macos.cc |
@@ -139,9 +139,11 @@ bool File::Lock(File::LockType lock, int64_t start, int64_t end) { |
fl.l_type = F_UNLCK; |
break; |
case File::kLockShared: |
+ case File::kLockBlockingShared: |
fl.l_type = F_RDLCK; |
break; |
case File::kLockExclusive: |
+ case File::kLockBlockingExclusive: |
fl.l_type = F_WRLCK; |
break; |
default: |
@@ -150,9 +152,12 @@ bool File::Lock(File::LockType lock, int64_t start, int64_t end) { |
fl.l_whence = SEEK_SET; |
fl.l_start = start; |
fl.l_len = end == -1 ? 0 : end - start; |
- // fcntl does not block, but fails if the lock cannot be acquired. |
- int rc = fcntl(handle_->fd(), F_SETLK, &fl); |
- return rc != -1; |
+ int cmd = F_SETLK; |
+ if ((lock == File::kLockBlockingShared) || |
+ (lock == File::kLockBlockingExclusive)) { |
+ cmd = F_SETLKW; |
+ } |
+ return TEMP_FAILURE_RETRY(fcntl(handle_->fd(), cmd, &fl)) != -1; |
} |