Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Unified Diff: runtime/bin/file_macos.cc

Issue 2050413002: Adds blocking file locks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update docs and CHANGELOG Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | sdk/lib/io/file.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698