Skip to content

Commit

Permalink
fix reentrancy in thrift
Browse files Browse the repository at this point in the history
Summary: title

Test Plan: unit tests

Reviewed By: davejwatson@fb.com

Subscribers: davejwatson, mcduff, trunkagent, alandau, bmatheny, mshneer, andreib, hitesh, andrewcox

FB internal diff: D1642655

Tasks: 5388156

Signature: t1:1642655:1414520348:60fbd2dd79729e965e93c95433210841d5d36ca5
  • Loading branch information
mshneer authored and Pavlo Kushnir committed Nov 8, 2014
1 parent fb7ec42 commit 4418d1e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions thrift/lib/cpp2/async/Cpp2Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ void Cpp2Channel::writeSuccess() noexcept {
assert(sendCallbacks_.size() > 0);

DestructorGuard dg(this);
for (auto& cb : sendCallbacks_.front()) {
auto sendCallbacks = std::move(sendCallbacks_.front());
sendCallbacks_.pop_front();
for (auto& cb : sendCallbacks) {
cb->messageSent();
}
sendCallbacks_.pop_front();
}

void Cpp2Channel::writeError(size_t bytesWritten,
Expand All @@ -215,11 +216,12 @@ void Cpp2Channel::writeError(size_t bytesWritten,

DestructorGuard dg(this);
VLOG(5) << "Got a write error: " << folly::exceptionStr(ex);
for (auto& cb : sendCallbacks_.front()) {
cb->messageSendError(
folly::make_exception_wrapper<TTransportException>(ex));
}
auto sendCallbacks = std::move(sendCallbacks_.front());
sendCallbacks_.pop_front();
for (auto& cb : sendCallbacks) {
cb->messageSendError(
folly::make_exception_wrapper<TTransportException>(ex));
}
}

void Cpp2Channel::processReadEOF() noexcept {
Expand Down

0 comments on commit 4418d1e

Please sign in to comment.