proxygen
folly::HandshakeCallback Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::HandshakeCallback:
folly::AsyncSSLSocket::HandshakeCB

Public Types

enum  ExpectType { EXPECT_SUCCESS, EXPECT_ERROR }
 

Public Member Functions

 HandshakeCallback (ReadCallbackBase *rcb, ExpectType expect=EXPECT_SUCCESS)
 
void setSocket (const std::shared_ptr< AsyncSSLSocket > &socket)
 
void setState (StateEnum s)
 
void handshakeSuc (AsyncSSLSocket *sock) noexceptoverride
 
void handshakeErr (AsyncSSLSocket *, const AsyncSocketException &ex) noexceptoverride
 
void waitForHandshake ()
 
 ~HandshakeCallback () override
 
void closeSocket ()
 
std::shared_ptr< AsyncSSLSocketgetSocket ()
 
- Public Member Functions inherited from folly::AsyncSSLSocket::HandshakeCB
virtual ~HandshakeCB ()=default
 
virtual bool handshakeVer (AsyncSSLSocket *, bool preverifyOk, X509_STORE_CTX *) noexcept
 

Public Attributes

StateEnum state
 
std::shared_ptr< AsyncSSLSocketsocket_
 
ReadCallbackBasercb_
 
ExpectType expect_
 
std::mutex mutex_
 
std::condition_variable cv_
 
std::string errorString_
 

Detailed Description

Definition at line 478 of file AsyncSSLSocketTest.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

folly::HandshakeCallback::HandshakeCallback ( ReadCallbackBase rcb,
ExpectType  expect = EXPECT_SUCCESS 
)
inlineexplicit

Definition at line 482 of file AsyncSSLSocketTest.h.

485  : state(STATE_WAITING), rcb_(rcb), expect_(expect) {}
void expect(LineReader &lr, const char *expected)
folly::HandshakeCallback::~HandshakeCallback ( )
inlineoverride

Definition at line 525 of file AsyncSSLSocketTest.h.

References EXPECT_EQ, and folly::STATE_SUCCEEDED.

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

Member Function Documentation

void folly::HandshakeCallback::closeSocket ( )
inline

Definition at line 529 of file AsyncSSLSocketTest.h.

References folly::SendMsgParamsCallbackBase::socket_, and folly::STATE_SUCCEEDED.

Referenced by folly::TEST().

529  {
530  socket_->close();
532  }
std::shared_ptr< AsyncSSLSocket > socket_
state
Definition: http_parser.c:272
std::shared_ptr<AsyncSSLSocket> folly::HandshakeCallback::getSocket ( )
inline

Definition at line 534 of file AsyncSSLSocketTest.h.

References folly::SendMsgParamsCallbackBase::socket_.

Referenced by folly::TEST().

534  {
535  return socket_;
536  }
std::shared_ptr< AsyncSSLSocket > socket_
void folly::HandshakeCallback::handshakeErr ( AsyncSSLSocket sock,
const AsyncSocketException ex 
)
inlineoverridevirtualnoexcept

handshakeErr() is called if an error occurs while establishing the SSL connection.

The HandshakeCB will be uninstalled before handshakeErr() is called.

Parameters
sockSSL socket on which the handshake was initiated
exAn exception representing the error.

Implements folly::AsyncSSLSocket::HandshakeCB.

Definition at line 506 of file AsyncSSLSocketTest.h.

References cv_, g(), mutex_, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.

508  {
509  std::lock_guard<std::mutex> g(mutex_);
510  cv_.notify_all();
511  std::cerr << "HandshakeCallback::handshakeError " << ex.what() << std::endl;
513  if (expect_ == EXPECT_ERROR) {
514  // rcb will never be invoked
516  }
517  errorString_ = ex.what();
518  }
void setState(StateEnum s)
std::condition_variable cv_
g_t g(f_t)
state
Definition: http_parser.c:272
void folly::HandshakeCallback::handshakeSuc ( AsyncSSLSocket sock)
inlineoverridevirtualnoexcept

handshakeSuc() is called when a new SSL connection is established, i.e., after SSL_accept/connect() returns successfully.

The HandshakeCB will be uninstalled before handshakeSuc() is called.

Parameters
sockSSL socket on which the handshake was initiated

Implements folly::AsyncSSLSocket::HandshakeCB.

Definition at line 497 of file AsyncSSLSocketTest.h.

References cv_, EXPECT_EQ, g(), mutex_, folly::SendMsgParamsCallbackBase::socket_, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.

497  {
498  std::lock_guard<std::mutex> g(mutex_);
499  cv_.notify_all();
500  EXPECT_EQ(sock, socket_.get());
501  std::cerr << "HandshakeCallback::connectionAccepted" << std::endl;
503  sock->setReadCB(rcb_);
505  }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::condition_variable cv_
std::shared_ptr< AsyncSSLSocket > socket_
g_t g(f_t)
state
Definition: http_parser.c:272
void setSocket(const std::shared_ptr< AsyncSSLSocket > &socket)
void folly::HandshakeCallback::setSocket ( const std::shared_ptr< AsyncSSLSocket > &  socket)
inline

Definition at line 487 of file AsyncSSLSocketTest.h.

References folly::netops::socket(), and folly::SendMsgParamsCallbackBase::socket_.

487  {
488  socket_ = socket;
489  }
std::shared_ptr< AsyncSSLSocket > socket_
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412
void folly::HandshakeCallback::setState ( StateEnum  s)
inline

Definition at line 491 of file AsyncSSLSocketTest.h.

References s.

491  {
492  state = s;
493  rcb_->setState(s);
494  }
void setState(StateEnum s)
static set< string > s
state
Definition: http_parser.c:272
void folly::HandshakeCallback::waitForHandshake ( )
inline

Definition at line 520 of file AsyncSSLSocketTest.h.

References cv_, folly::lock(), mutex_, and folly::STATE_WAITING.

Referenced by folly::TEST().

520  {
521  std::unique_lock<std::mutex> lock(mutex_);
522  cv_.wait(lock, [this] { return state != STATE_WAITING; });
523  }
std::condition_variable cv_
auto lock(Synchronized< D, M > &synchronized, Args &&...args)
state
Definition: http_parser.c:272

Member Data Documentation

std::condition_variable folly::HandshakeCallback::cv_

Definition at line 543 of file AsyncSSLSocketTest.h.

std::string folly::HandshakeCallback::errorString_

Definition at line 544 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

ExpectType folly::HandshakeCallback::expect_

Definition at line 541 of file AsyncSSLSocketTest.h.

std::mutex folly::HandshakeCallback::mutex_

Definition at line 542 of file AsyncSSLSocketTest.h.

ReadCallbackBase* folly::HandshakeCallback::rcb_

Definition at line 540 of file AsyncSSLSocketTest.h.

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

Definition at line 539 of file AsyncSSLSocketTest.h.

StateEnum folly::HandshakeCallback::state

Definition at line 538 of file AsyncSSLSocketTest.h.


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