Skip to content

Commit 3a89132

Browse files
Yu-Ho Hsiehfacebook-github-bot
Yu-Ho Hsieh
authored andcommitted
Move sendAbort to the end of invariantViolation()
Summary: The commits moves the `sendAbort()` to the end of invarian violation logic and add the delay destructor to the `invariantViolation` . This way the service handler can invoke customized send error implementation without being worrid about keeping the transaction around. Reviewed By: hanidamlaj Differential Revision: D69196385 fbshipit-source-id: 82c17e6a8ac610db228af0611f64f35a7c6274cc
1 parent f2d4044 commit 3a89132

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

third-party/proxygen/src/proxygen/lib/http/session/HTTPTransaction.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,18 @@ bool HTTPTransaction::validateEgressStateTransition(
640640
}
641641

642642
void HTTPTransaction::invariantViolation(HTTPException ex) {
643+
DestructorGuard g(this);
643644
LOG(ERROR) << "invariantViolation msg=" << ex.what()
644645
<< " aborted_=" << uint32_t(aborted_) << " " << *this;
645-
sendAbort();
646646
if (handler_) {
647647
handler_->onInvariantViolation(ex);
648648
} else {
649649
LOG(FATAL) << "Invariant violation with no handler; ex=" << ex.what();
650650
}
651+
// In http/1.1, this will send TCP reset and ungracefully terminate the
652+
// connection. In h2, this will send stream reset but keep the connection
653+
// open.
654+
sendAbort(ErrorCode::NO_ERROR);
651655
}
652656

653657
void HTTPTransaction::abortAndDeliverError(ErrorCode codecError,

third-party/proxygen/src/proxygen/lib/http/session/HTTPTransaction.h

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class HTTPTransactionHandler : public TraceEventObserver {
257257
* invoked in cases that violate an internal invariant that is fatal to the
258258
* transaction but can be recoverable for the session or library. One such
259259
* example is mis-use of the egress APIs (sendBody() before sendHeaders()).
260+
*
260261
*/
261262
virtual void onInvariantViolation(const HTTPException& error) noexcept {
262263
LOG(FATAL) << error.what();

third-party/proxygen/src/proxygen/lib/http/session/test/DownstreamTransactionTest.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ TEST_F(DownstreamTransactionTest, InvariantViolationHandler) {
158158
EXPECT_CALL(transport_, sendAbort(_, _));
159159
EXPECT_CALL(handler_, _detachTransaction());
160160
EXPECT_CALL(transport_, detach(&txn));
161-
162161
txn.setHandler(&handler_);
163162
// Send body before headers -- oops;
164163
txn.sendBody(makeBuf(10));

0 commit comments

Comments
 (0)