Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible asan #4

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions env/fs_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ class PosixFileSystem : public FileSystem {
lhi.acquire_time = current_time;
lhi.acquiring_thread = Env::Default()->GetThreadID();

IOStatus result = IOStatus::OK();

mutex_locked_files.Lock();
// If it already exists in the locked_files set, then it is already locked,
// and fail this lock attempt. Otherwise, insert it into locked_files.
Expand All @@ -767,18 +769,18 @@ class PosixFileSystem : public FileSystem {
const auto it_success = locked_files.insert({fname, lhi});
if (it_success.second == false) {
LockHoldingInfo& prev_info = it_success.first->second;
mutex_locked_files.Unlock();
errno = ENOLCK;
// Note that the thread ID printed is the same one as the one in
// posix logger, but posix logger prints it hex format.
return IOError("lock hold by current process, acquire time " +
result = IOError("lock hold by current process, acquire time " +
ToString(prev_info.acquire_time) +
" acquiring thread " +
ToString(prev_info.acquiring_thread),
fname, errno);
mutex_locked_files.Unlock();
return result;
}

IOStatus result = IOStatus::OK();
int fd;
int flags = cloexec_flags(O_RDWR | O_CREAT, nullptr);

Expand Down