Index: runtime/bin/file_android.cc |
diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc |
index 8b8612100c5e2928f1889f49a7ada0e5f6a23634..9bcf44c8334e8c8361d8fc764398ba133705257d 100644 |
--- a/runtime/bin/file_android.cc |
+++ b/runtime/bin/file_android.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; |
} |