From 80e85cb30f214653b33ac7fd8d70614a1d3648fc Mon Sep 17 00:00:00 2001 From: Yang Chi Date: Thu, 10 Oct 2019 10:17:33 -0700 Subject: [PATCH] Add drain state to HQSession describe string Summary: This makes it much easier to understand session's state when going through error messages Reviewed By: mjoras Differential Revision: D17126115 fbshipit-source-id: 2a90a3d56cf9db5f0ed576528d3257b414b73adb --- proxygen/lib/http/session/HQSession.cpp | 29 +++++++++++++++++++++++++ proxygen/lib/http/session/HQSession.h | 6 +++++ 2 files changed, 35 insertions(+) diff --git a/proxygen/lib/http/session/HQSession.cpp b/proxygen/lib/http/session/HQSession.cpp index 01aab8ebd..f84483608 100644 --- a/proxygen/lib/http/session/HQSession.cpp +++ b/proxygen/lib/http/session/HQSession.cpp @@ -3906,4 +3906,33 @@ std::ostream& operator<<(std::ostream& os, const HQSession& session) { return os; } +std::ostream& operator<<(std::ostream& os, HQSession::DrainState drainState) { + switch (drainState) { + case HQSession::DrainState::NONE: + os << "none"; + break; + case HQSession::DrainState::PENDING: + os << "pending"; + break; + case HQSession::DrainState::CLOSE_SENT: + os << "close_sent"; + break; + case HQSession::DrainState::CLOSE_RECEIVED: + os << "close_recvd"; + break; + case HQSession::DrainState::FIRST_GOAWAY: + os << "first_goaway"; + break; + case HQSession::DrainState::SECOND_GOAWAY: + os << "second_goaway"; + break; + case HQSession::DrainState::DONE: + os << "done"; + break; + default: + folly::assume_unreachable(); + } + return os; +} + } // namespace proxygen diff --git a/proxygen/lib/http/session/HQSession.h b/proxygen/lib/http/session/HQSession.h index ba27794d1..f536bffe8 100644 --- a/proxygen/lib/http/session/HQSession.h +++ b/proxygen/lib/http/session/HQSession.h @@ -267,6 +267,7 @@ class HQSession << ", local=" << getLocalAddress() << ", " << getPeerAddress() << "=upstream"; } + os << ", drain=" << drainState_; } void onGoaway(uint64_t lastGoodStreamID, @@ -2235,6 +2236,11 @@ class HQSession // NOTE: introduce better decoupling between the streams // and the containing session, then remove the friendship. friend class HQStreamBase; + + // To let the operator<< access DrainState which is private + friend std::ostream& operator<<(std::ostream&, DrainState); }; // HQSession +std::ostream& operator<<(std::ostream& os, HQSession::DrainState drainState); + } // namespace proxygen