proxygen
wangle::AcceptorHandshakeManager Class Referenceabstract

#include <AcceptorHandshakeManager.h>

Inheritance diagram for wangle::AcceptorHandshakeManager:
wangle::ManagedConnection wangle::AcceptorHandshakeHelper::Callback folly::HHWheelTimer::Callback folly::DelayedDestruction folly::DelayedDestructionBase wangle::PeekingAcceptorHandshakeManager

Public Member Functions

 AcceptorHandshakeManager (Acceptor *acceptor, const folly::SocketAddress &clientAddr, std::chrono::steady_clock::time_point acceptTime, TransportInfo tinfo)
 
 ~AcceptorHandshakeManager () override=default
 
virtual void start (folly::AsyncSSLSocket::UniquePtr sock) noexcept
 
void timeoutExpired () noexceptoverride
 
void describe (std::ostream &os) const override
 
bool isBusy () const override
 
void notifyPendingShutdown () override
 
void closeWhenIdle () override
 
void dropConnection () override
 
void dropConnection (SSLErrorEnum reason)
 
void dumpConnectionState (uint8_t) override
 
- Public Member Functions inherited from wangle::ManagedConnection
 ManagedConnection ()
 
virtual std::chrono::milliseconds getIdleTime () const
 
void fireNotifyPendingShutdown ()
 
void fireCloseWhenIdle (bool force_to_close=false)
 
virtual void resetTimeout ()
 
void resetTimeoutTo (std::chrono::milliseconds)
 
virtual void scheduleTimeout (folly::HHWheelTimer::Callback *callback, std::chrono::milliseconds timeout)
 
ConnectionManagergetConnectionManager ()
 
- Public Member Functions inherited from folly::HHWheelTimer::Callback
 Callback ()=default
 
virtual ~Callback ()
 
virtual void callbackCanceled () noexcept
 
void cancelTimeout ()
 
bool isScheduled () const
 
std::chrono::milliseconds getTimeRemaining ()
 
- Public Member Functions inherited from folly::DelayedDestruction
virtual void destroy ()
 
bool getDestroyPending () const
 
- Public Member Functions inherited from folly::DelayedDestructionBase
virtual ~DelayedDestructionBase ()=default
 
- Public Member Functions inherited from wangle::AcceptorHandshakeHelper::Callback
virtual ~Callback ()=default
 

Protected Member Functions

void connectionReady (folly::AsyncTransportWrapper::UniquePtr transport, std::string nextProtocol, SecureTransportType secureTransportType, folly::Optional< SSLErrorEnum > details) noexceptoverride
 
void connectionError (folly::AsyncTransportWrapper *transport, folly::exception_wrapper ex, folly::Optional< SSLErrorEnum > details) noexceptoverride
 
std::chrono::milliseconds timeSinceAcceptMs () const
 
virtual void startHelper (folly::AsyncSSLSocket::UniquePtr sock)=0
 
void startHandshakeTimeout ()
 
- Protected Member Functions inherited from wangle::ManagedConnection
 ~ManagedConnection () override
 
- Protected Member Functions inherited from folly::HHWheelTimer::Callback
virtual std::chrono::steady_clock::time_point getCurTime ()
 
- Protected Member Functions inherited from folly::DelayedDestruction
 ~DelayedDestruction () override=default
 
 DelayedDestruction ()
 
- Protected Member Functions inherited from folly::DelayedDestructionBase
 DelayedDestructionBase ()
 
uint32_t getDestructorGuardCount () const
 

Protected Attributes

Acceptoracceptor_
 
folly::SocketAddress clientAddr_
 
std::chrono::steady_clock::time_point acceptTime_
 
TransportInfo tinfo_
 
AcceptorHandshakeHelper::UniquePtr helper_
 

Detailed Description

Definition at line 70 of file AcceptorHandshakeManager.h.

Constructor & Destructor Documentation

wangle::AcceptorHandshakeManager::AcceptorHandshakeManager ( Acceptor acceptor,
const folly::SocketAddress clientAddr,
std::chrono::steady_clock::time_point  acceptTime,
TransportInfo  tinfo 
)
inline

Definition at line 73 of file AcceptorHandshakeManager.h.

References folly::pushmi::__adl::noexcept(), and wangle::AcceptorHandshakeHelper::start().

77  :
78  acceptor_(acceptor),
79  clientAddr_(clientAddr),
80  acceptTime_(acceptTime),
81  tinfo_(std::move(tinfo)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::chrono::steady_clock::time_point acceptTime_
wangle::AcceptorHandshakeManager::~AcceptorHandshakeManager ( )
overridedefault

Member Function Documentation

void wangle::AcceptorHandshakeManager::closeWhenIdle ( )
inlineoverridevirtual

Instruct the connection that it should shutdown as soon as it is safe. This is called after notifyPendingShutdown().

Implements wangle::ManagedConnection.

Definition at line 102 of file AcceptorHandshakeManager.h.

102 {}
void wangle::AcceptorHandshakeManager::connectionError ( folly::AsyncTransportWrapper transport,
folly::exception_wrapper  ex,
folly::Optional< SSLErrorEnum sslErr 
)
overrideprotectedvirtualnoexcept

Called if an error was encountered while performing handshake.

If sslErr is set, Acceptor::updateSSLStats will be called.

Implements wangle::AcceptorHandshakeHelper::Callback.

Definition at line 52 of file AcceptorHandshakeManager.cpp.

References acceptor_, destroy(), and folly::gen::move.

55  {
56  if (sslErr) {
58  transport, timeSinceAcceptMs(), sslErr.value());
59  }
62  destroy();
63 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual void updateSSLStats(const folly::AsyncTransportWrapper *, std::chrono::milliseconds, SSLErrorEnum) noexcept
Definition: Acceptor.h:305
void removeConnection(ManagedConnection *connection)
std::chrono::milliseconds timeSinceAcceptMs() const
virtual wangle::ConnectionManager * getConnectionManager()
Definition: Acceptor.h:132
virtual void sslConnectionError(const folly::exception_wrapper &ex)
Definition: Acceptor.cpp:422
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
void wangle::AcceptorHandshakeManager::connectionReady ( folly::AsyncTransportWrapper::UniquePtr  transport,
std::string  nextProtocol,
SecureTransportType  secureTransportType,
folly::Optional< SSLErrorEnum sslErr 
)
overrideprotectedvirtualnoexcept

Called after handshake has been completed successfully.

If sslErr is set, Acceptor::updateSSLStats will be called.

Implements wangle::AcceptorHandshakeHelper::Callback.

Definition at line 29 of file AcceptorHandshakeManager.cpp.

References acceptor_, destroy(), and folly::gen::move.

33  {
34  if (sslErr) {
36  transport.get(),
38  sslErr.value());
39  }
41  // We pass TransportInfo by reference even though we're about to destroy it,
42  // so lets hope that anything saving it makes a copy!
44  std::move(transport),
46  std::move(nextProtocol),
47  secureTransportType,
48  tinfo_);
49  destroy();
50 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual void updateSSLStats(const folly::AsyncTransportWrapper *, std::chrono::milliseconds, SSLErrorEnum) noexcept
Definition: Acceptor.h:305
void removeConnection(ManagedConnection *connection)
std::chrono::milliseconds timeSinceAcceptMs() const
virtual void sslConnectionReady(folly::AsyncTransportWrapper::UniquePtr sock, const folly::SocketAddress &clientAddr, const std::string &nextProtocol, SecureTransportType secureTransportType, TransportInfo &tinfo)
Definition: Acceptor.cpp:403
virtual wangle::ConnectionManager * getConnectionManager()
Definition: Acceptor.h:132
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
void wangle::AcceptorHandshakeManager::describe ( std::ostream &  os) const
inlineoverridevirtual

Print a human-readable description of the connection.

Parameters
osDestination stream.

Implements wangle::ManagedConnection.

Definition at line 92 of file AcceptorHandshakeManager.h.

92  {
93  os << "pending handshake on " << clientAddr_;
94  }
void wangle::AcceptorHandshakeManager::dropConnection ( )
inlineoverridevirtual

Forcibly drop a connection.

If a request is in progress, this should cause the connection to be closed with a reset.

Implements wangle::ManagedConnection.

Definition at line 104 of file AcceptorHandshakeManager.h.

References wangle::AcceptorHandshakeHelper::dropConnection(), and wangle::NO_ERROR.

void wangle::AcceptorHandshakeManager::dropConnection ( SSLErrorEnum  reason)
inline

Definition at line 108 of file AcceptorHandshakeManager.h.

108  {
109  VLOG(10) << "Dropping in progress handshake for " << clientAddr_;
110  helper_->dropConnection(reason);
111  }
AcceptorHandshakeHelper::UniquePtr helper_
void wangle::AcceptorHandshakeManager::dumpConnectionState ( uint8_t  loglevel)
inlineoverridevirtual
bool wangle::AcceptorHandshakeManager::isBusy ( ) const
inlineoverridevirtual

Check whether the connection has any requests outstanding.

Implements wangle::ManagedConnection.

Definition at line 96 of file AcceptorHandshakeManager.h.

96  {
97  return true;
98  }
void wangle::AcceptorHandshakeManager::notifyPendingShutdown ( )
inlineoverridevirtual

Notify the connection that a shutdown is pending. This method will be called at the beginning of graceful shutdown.

Implements wangle::ManagedConnection.

Definition at line 100 of file AcceptorHandshakeManager.h.

100 {}
void wangle::AcceptorHandshakeManager::start ( folly::AsyncSSLSocket::UniquePtr  sock)
virtualnoexcept

Definition at line 22 of file AcceptorHandshakeManager.cpp.

References acceptor_, and folly::gen::move.

Referenced by wangle::Acceptor::startHandshakeManager().

23  {
25  startHelper(std::move(sock));
27 }
void addConnection(ManagedConnection *connection, bool timeout=false)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual void startHelper(folly::AsyncSSLSocket::UniquePtr sock)=0
virtual wangle::ConnectionManager * getConnectionManager()
Definition: Acceptor.h:132
void wangle::AcceptorHandshakeManager::startHandshakeTimeout ( )
protected

Definition at line 70 of file AcceptorHandshakeManager.cpp.

References acceptor_, wangle::Acceptor::getConnectionManager(), wangle::Acceptor::getSSLHandshakeTimeout(), and wangle::ConnectionManager::scheduleTimeout().

70  {
71  auto handshake_timeout = acceptor_->getSSLHandshakeTimeout();
73  this, handshake_timeout);
74 }
std::chrono::milliseconds getSSLHandshakeTimeout() const
Definition: Acceptor.h:169
void scheduleTimeout(ManagedConnection *const connection, std::chrono::milliseconds timeout)
virtual wangle::ConnectionManager * getConnectionManager()
Definition: Acceptor.h:132
virtual void wangle::AcceptorHandshakeManager::startHelper ( folly::AsyncSSLSocket::UniquePtr  sock)
protectedpure virtual
void wangle::AcceptorHandshakeManager::timeoutExpired ( )
inlineoverridevirtualnoexcept

timeoutExpired() is invoked when the timeout has expired.

Implements wangle::ManagedConnection.

Definition at line 87 of file AcceptorHandshakeManager.h.

References wangle::AcceptorHandshakeHelper::dropConnection(), and wangle::TIMEOUT.

87  {
88  VLOG(4) << "SSL handshake timeout expired";
90  }
std::chrono::milliseconds wangle::AcceptorHandshakeManager::timeSinceAcceptMs ( ) const
protected

Definition at line 65 of file AcceptorHandshakeManager.cpp.

References acceptTime_, and now().

65  {
66  return std::chrono::duration_cast<std::chrono::milliseconds>(
68 }
std::chrono::steady_clock::time_point now()
std::chrono::steady_clock::time_point acceptTime_

Member Data Documentation

Acceptor* wangle::AcceptorHandshakeManager::acceptor_
protected

Definition at line 135 of file AcceptorHandshakeManager.h.

Referenced by startHandshakeTimeout().

std::chrono::steady_clock::time_point wangle::AcceptorHandshakeManager::acceptTime_
protected

Definition at line 137 of file AcceptorHandshakeManager.h.

Referenced by timeSinceAcceptMs().

folly::SocketAddress wangle::AcceptorHandshakeManager::clientAddr_
protected

Definition at line 136 of file AcceptorHandshakeManager.h.

AcceptorHandshakeHelper::UniquePtr wangle::AcceptorHandshakeManager::helper_
protected

Definition at line 139 of file AcceptorHandshakeManager.h.

TransportInfo wangle::AcceptorHandshakeManager::tinfo_
protected

Definition at line 138 of file AcceptorHandshakeManager.h.


The documentation for this class was generated from the following files: