proxygen
folly::SSLServerAcceptCallbackBase Class Referenceabstract

#include <TestSSLServer.h>

Inheritance diagram for folly::SSLServerAcceptCallbackBase:
folly::AsyncServerSocket::AcceptCallback folly::ConnectTimeoutCallback folly::HandshakeErrorCallback folly::HandshakeTimeoutCallback folly::SSLServerAcceptCallback folly::SSLServerAcceptCallbackDelay folly::SSLServerAsyncCacheAcceptCallback

Public Member Functions

 SSLServerAcceptCallbackBase (HandshakeCallback *hcb)
 
 ~SSLServerAcceptCallbackBase () override
 
void acceptError (const std::exception &ex) noexceptoverride
 
void connectionAccepted (int fd, const SocketAddress &) noexceptoverride
 
virtual void connAccepted (const std::shared_ptr< AsyncSSLSocket > &s)=0
 
void detach ()
 
- Public Member Functions inherited from folly::AsyncServerSocket::AcceptCallback
virtual ~AcceptCallback ()=default
 
virtual void acceptStarted () noexcept
 
virtual void acceptStopped () noexcept
 

Public Attributes

StateEnum state
 
HandshakeCallbackhcb_
 
std::shared_ptr< SSLContextctx_
 
std::shared_ptr< AsyncSSLSocketsocket_
 
EventBasebase_
 

Detailed Description

Definition at line 49 of file TestSSLServer.h.

Constructor & Destructor Documentation

folly::SSLServerAcceptCallbackBase::SSLServerAcceptCallbackBase ( HandshakeCallback hcb)
inlineexplicit
folly::SSLServerAcceptCallbackBase::~SSLServerAcceptCallbackBase ( )
inlineoverride

Definition at line 54 of file TestSSLServer.h.

References EXPECT_EQ, and folly::STATE_SUCCEEDED.

54  {
56  }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
state
Definition: http_parser.c:272

Member Function Documentation

void folly::SSLServerAcceptCallbackBase::acceptError ( const std::exception &  ex)
inlineoverridevirtualnoexcept

acceptError() is called if an error occurs while accepting.

The AcceptCallback will remain installed even after an accept error, as the errors are typically somewhat transient, such as being out of file descriptors. The server socket must be explicitly stopped if you wish to stop accepting after an error.

Parameters
exAn exception representing the error.

Implements folly::AsyncServerSocket::AcceptCallback.

Definition at line 58 of file TestSSLServer.h.

References folly::STATE_FAILED, and folly::WARNING.

Referenced by connectionAccepted().

58  {
59  LOG(WARNING) << "SSLServerAcceptCallbackBase::acceptError " << ex.what();
61  }
state
Definition: http_parser.c:272
virtual void folly::SSLServerAcceptCallbackBase::connAccepted ( const std::shared_ptr< AsyncSSLSocket > &  s)
pure virtual
void folly::SSLServerAcceptCallbackBase::connectionAccepted ( int  fd,
const SocketAddress clientAddr 
)
inlineoverridevirtualnoexcept

connectionAccepted() is called whenever a new client connection is received.

The AcceptCallback will remain installed after connectionAccepted() returns.

Parameters
fdThe newly accepted client socket. The AcceptCallback assumes ownership of this socket, and is responsible for closing it when done. The newly accepted file descriptor will have already been put into non-blocking mode.
clientAddrA reference to a SocketAddress struct containing the client's address. This struct is only guaranteed to remain valid until connectionAccepted() returns.

Implements folly::AsyncServerSocket::AcceptCallback.

Definition at line 63 of file TestSSLServer.h.

References acceptError(), base_, folly::netops::close(), connAccepted(), ctx_, folly::INFO, folly::AsyncSSLSocket::newSocket(), s, and socket_.

65  {
66  if (socket_) {
67  socket_->detachEventBase();
68  }
69  LOG(INFO) << "Connection accepted";
70  try {
71  // Create a AsyncSSLSocket object with the fd. The socket should be
72  // added to the event base and in the state of accepting SSL connection.
74  } catch (const std::exception& e) {
75  LOG(ERROR) << "Exception %s caught while creating a AsyncSSLSocket "
76  "object with socket "
77  << e.what() << fd;
78  ::close(fd);
79  acceptError(e);
80  return;
81  }
82 
84  }
virtual void connAccepted(const std::shared_ptr< AsyncSSLSocket > &s)=0
std::shared_ptr< AsyncSSLSocket > socket_
Definition: TestSSLServer.h:97
static std::shared_ptr< AsyncSSLSocket > newSocket(const std::shared_ptr< folly::SSLContext > &ctx, EventBase *evb, int fd, bool server=true, bool deferSecurityNegotiation=false)
void acceptError(const std::exception &ex) noexceptoverride
Definition: TestSSLServer.h:58
int close(NetworkSocket s)
Definition: NetOps.cpp:90
std::shared_ptr< SSLContext > ctx_
Definition: TestSSLServer.h:96
void folly::SSLServerAcceptCallbackBase::detach ( )
inline

Definition at line 88 of file TestSSLServer.h.

References socket_.

Referenced by folly::TestSSLServer::init().

88  {
89  if (socket_) {
90  socket_->detachEventBase();
91  }
92  }
std::shared_ptr< AsyncSSLSocket > socket_
Definition: TestSSLServer.h:97

Member Data Documentation

EventBase* folly::SSLServerAcceptCallbackBase::base_

Definition at line 98 of file TestSSLServer.h.

Referenced by connectionAccepted(), and folly::TestSSLServer::init().

std::shared_ptr<SSLContext> folly::SSLServerAcceptCallbackBase::ctx_

Definition at line 96 of file TestSSLServer.h.

Referenced by connectionAccepted(), and folly::TestSSLServer::init().

HandshakeCallback* folly::SSLServerAcceptCallbackBase::hcb_

Definition at line 95 of file TestSSLServer.h.

std::shared_ptr<AsyncSSLSocket> folly::SSLServerAcceptCallbackBase::socket_

Definition at line 97 of file TestSSLServer.h.

Referenced by connectionAccepted(), and detach().

StateEnum folly::SSLServerAcceptCallbackBase::state

Definition at line 94 of file TestSSLServer.h.


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