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