Commit d7395200 authored by Bill Earl's avatar Bill Earl Committed by Facebook Github Bot

Fix another TSAN lock inversion in folly::RequestContext

Summary:
TSAN complains about a lock inversion between folly/io/async/Request.cpp
lines 242 and 277.  The code as 242 was changed to use folly::acquireLocked() in
D9797715, but the code at 277 needs to be changed in the same way (except for
requesting a write lock on the child)

Reviewed By: kennyyu

Differential Revision: D10251470

fbshipit-source-id: c476a3664bfe83edbddbd402cf568eac885b9123
parent defda21d
...@@ -273,8 +273,9 @@ RequestContext::setShallowCopyContext() { ...@@ -273,8 +273,9 @@ RequestContext::setShallowCopyContext() {
auto child = std::make_shared<RequestContext>(); auto child = std::make_shared<RequestContext>();
if (parent) { if (parent) {
auto parentLock = parent->state_.rlock(); auto ret = folly::acquireLocked(as_const(parent->state_), child->state_);
auto childLock = child->state_.wlock(); auto& parentLock = std::get<0>(ret);
auto& childLock = std::get<1>(ret);
childLock->callbackData_ = parentLock->callbackData_; childLock->callbackData_ = parentLock->callbackData_;
childLock->requestData_.reserve(parentLock->requestData_.size()); childLock->requestData_.reserve(parentLock->requestData_.size());
for (const auto& entry : parentLock->requestData_) { for (const auto& entry : parentLock->requestData_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment