Index: runtime/bin/file_linux.cc |
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc |
index 2e47d74978a486a0fd1a202b9f365526459ac946..eab92d5361ea847ad8e7b8064a6d47c9f86bdecf 100644 |
--- a/runtime/bin/file_linux.cc |
+++ b/runtime/bin/file_linux.cc |
@@ -136,9 +136,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: |
@@ -147,9 +149,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; |
} |