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

Issue 1491743009: [base] POSIX File::Unlock() didn't actually unlock file. (Closed)

Created:
5 years ago by Scott Hess - ex-Googler
Modified:
5 years ago
Reviewers:
Lei Zhang
CC:
chromium-reviews, vmpstr+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[base] POSIX File::Unlock() didn't actually unlock file. Unlock passed F_UNLCK as cmd to fcntl(). It's supposed to be in flock.type. As a result, the file is not actually unlocked. F_UNLCK is 2 (on OSX and Linux), cmd 2 is F_SETFD, which sets flags on the file descriptor, which is why the call succeeds. The only flag defined appears to be FD_CLOEXEC, which is the low-order bit of the third parameter. Since the parameter passed to fcntl is aligned at off_t or better, Unlock() will clear FD_CLOEXEC if set. As best I can tell cases with FD_CLOEXEC do not use base::File. [Addendum: File::Lock/Unlock was landed for leveldb, and at this time Chromium's only use is in third_party/leveldatabase/env_chromium.cc.] BUG=565787 Committed: https://crrev.com/e66da3f22aee5e74d107f961843c07b8d4e311f3 Cr-Commit-Position: refs/heads/master@{#364497}

Patch Set 1 #

Patch Set 2 : Try without fix to see what happens. #

Patch Set 3 : Back to original CL. #

Patch Set 4 : forgot some comments #

Total comments: 4

Patch Set 5 : Move lock tests to new file, with test fixture, share code. #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+234 lines, -2 lines) Patch
M base/BUILD.gn View 1 2 3 4 2 chunks +2 lines, -0 lines 0 comments Download
M base/base.gyp View 1 2 3 4 2 chunks +3 lines, -0 lines 0 comments Download
A base/files/file_locking_unittest.cc View 1 2 3 4 1 chunk +227 lines, -0 lines 6 comments Download
M base/files/file_posix.cc View 2 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 22 (6 generated)
Scott Hess - ex-Googler
Try without fix to see what happens.
5 years ago (2015-12-03 23:16:41 UTC) #1
Scott Hess - ex-Googler
Back to original CL.
5 years ago (2015-12-03 23:17:45 UTC) #2
Scott Hess - ex-Googler
forgot some comments
5 years ago (2015-12-03 23:23:02 UTC) #3
Scott Hess - ex-Googler
Previous fcntl CL was because I was checking the locking strategy for purposes of prototyping ...
5 years ago (2015-12-03 23:26:44 UTC) #5
Lei Zhang
How did we survive for this? Is there no bug #? How did you even ...
5 years ago (2015-12-04 03:23:03 UTC) #6
Lei Zhang
On 2015/12/04 03:23:03, Lei Zhang wrote: > How did you even find this problem? Oh, ...
5 years ago (2015-12-04 03:25:03 UTC) #7
Scott Hess - ex-Googler
On 2015/12/04 03:23:03, Lei Zhang wrote: > How did we survive for this? Is there ...
5 years ago (2015-12-04 06:40:34 UTC) #8
Lei Zhang
https://codereview.chromium.org/1491743009/diff/60001/base/files/file_unittest.cc File base/files/file_unittest.cc (right): https://codereview.chromium.org/1491743009/diff/60001/base/files/file_unittest.cc#newcode666 base/files/file_unittest.cc:666: CHECK(WaitForEvent(temp_path, kSignalLockFileClose)); On 2015/12/04 06:40:34, Scott Hess wrote: > ...
5 years ago (2015-12-04 16:57:54 UTC) #10
Scott Hess - ex-Googler
Move lock tests to new file, with test fixture, share code.
5 years ago (2015-12-08 00:46:20 UTC) #11
Scott Hess - ex-Googler
On 2015/12/08 00:46:20, Scott Hess wrote: > Move lock tests to new file, with test ...
5 years ago (2015-12-08 00:50:37 UTC) #12
Scott Hess - ex-Googler
https://codereview.chromium.org/1491743009/diff/80001/base/files/file_locking_unittest.cc File base/files/file_locking_unittest.cc (right): https://codereview.chromium.org/1491743009/diff/80001/base/files/file_locking_unittest.cc#newcode135 base/files/file_locking_unittest.cc:135: ASSERT_EQ(File::FILE_OK, lock_file_.Unlock()); I just did a test reverting the ...
5 years ago (2015-12-08 00:55:44 UTC) #13
Lei Zhang
lgtm https://codereview.chromium.org/1491743009/diff/80001/base/files/file_locking_unittest.cc File base/files/file_locking_unittest.cc (right): https://codereview.chromium.org/1491743009/diff/80001/base/files/file_locking_unittest.cc#newcode1 base/files/file_locking_unittest.cc:1: // Copyright (c) 2015 The Chromium Authors. All ...
5 years ago (2015-12-10 04:02:52 UTC) #15
Scott Hess - ex-Googler
Thanks! https://codereview.chromium.org/1491743009/diff/80001/base/files/file_locking_unittest.cc File base/files/file_locking_unittest.cc (right): https://codereview.chromium.org/1491743009/diff/80001/base/files/file_locking_unittest.cc#newcode1 base/files/file_locking_unittest.cc:1: // Copyright (c) 2015 The Chromium Authors. All ...
5 years ago (2015-12-10 20:12:08 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1491743009/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1491743009/80001
5 years ago (2015-12-10 20:12:57 UTC) #18
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years ago (2015-12-10 22:12:24 UTC) #20
commit-bot: I haz the power
5 years ago (2015-12-10 22:13:16 UTC) #22
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/e66da3f22aee5e74d107f961843c07b8d4e311f3
Cr-Commit-Position: refs/heads/master@{#364497}

Powered by Google App Engine
This is Rietveld 408576698