proxygen
folly::TestSSLAsyncCacheServer Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::TestSSLAsyncCacheServer:
folly::TestSSLServer

Public Member Functions

 TestSSLAsyncCacheServer (SSLServerAcceptCallbackBase *acb, int lookupDelay=100)
 
uint32_t getAsyncCallbacks () const
 
uint32_t getAsyncLookups () const
 
- Public Member Functions inherited from folly::TestSSLServer
 TestSSLServer (SSLServerAcceptCallbackBase *acb, bool enableTFO=false)
 
 TestSSLServer (SSLServerAcceptCallbackBase *acb, std::shared_ptr< SSLContext > ctx, bool enableTFO=false)
 
virtual ~TestSSLServer ()
 
EventBasegetEventBase ()
 
void loadTestCerts ()
 
const SocketAddressgetAddress () const
 

Static Private Member Functions

static SSL_SESSION * getSessionCallback (SSL *ssl, unsigned char *, int, int *copyflag)
 

Static Private Attributes

static uint32_t asyncCallbacks_ = 0
 
static uint32_t asyncLookups_ = 0
 
static uint32_t lookupDelay_ = 0
 

Additional Inherited Members

- Protected Attributes inherited from folly::TestSSLServer
EventBase evb_
 
std::shared_ptr< SSLContextctx_
 
SSLServerAcceptCallbackBaseacb_
 
std::shared_ptr< AsyncServerSocketsocket_
 
SocketAddress address_
 
std::thread thread_
 

Detailed Description

Definition at line 714 of file AsyncSSLSocketTest.h.

Constructor & Destructor Documentation

folly::TestSSLAsyncCacheServer::TestSSLAsyncCacheServer ( SSLServerAcceptCallbackBase acb,
int  lookupDelay = 100 
)
inlineexplicit

Definition at line 716 of file AsyncSSLSocketTest.h.

References ctx_, and getSessionCallback().

719  : TestSSLServer(acb) {
720  SSL_CTX* sslCtx = ctx_->getSSLCtx();
721 #ifdef SSL_ERROR_WANT_SESS_CACHE_LOOKUP
722  SSL_CTX_sess_set_get_cb(
724 #endif
725  SSL_CTX_set_session_cache_mode(
726  sslCtx, SSL_SESS_CACHE_NO_INTERNAL | SSL_SESS_CACHE_SERVER);
727  asyncCallbacks_ = 0;
728  asyncLookups_ = 0;
729  lookupDelay_ = lookupDelay;
730  }
std::shared_ptr< SSLContext > ctx_
static SSL_SESSION * getSessionCallback(SSL *ssl, unsigned char *, int, int *copyflag)
TestSSLServer(SSLServerAcceptCallbackBase *acb, bool enableTFO=false)

Member Function Documentation

uint32_t folly::TestSSLAsyncCacheServer::getAsyncCallbacks ( ) const
inline

Definition at line 732 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

732  {
733  return asyncCallbacks_;
734  }
uint32_t folly::TestSSLAsyncCacheServer::getAsyncLookups ( ) const
inline

Definition at line 735 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

735  {
736  return asyncLookups_;
737  }
static SSL_SESSION* folly::TestSSLAsyncCacheServer::getSessionCallback ( SSL *  ssl,
unsigned char *  ,
int  ,
int *  copyflag 
)
inlinestaticprivate

Definition at line 744 of file AsyncSSLSocketTest.h.

References folly::netops::bind(), folly::getctx(), folly::AsyncSocket::getEventBase(), folly::getfds(), folly::AsyncSSLSocket::getFromSSL(), folly::AsyncSSLSocket::restartSSLAccept(), folly::sslsocketpair(), and folly::TimeoutManager::tryRunAfterDelay().

Referenced by TestSSLAsyncCacheServer().

748  {
749  *copyflag = 0;
750  asyncCallbacks_++;
751  (void)ssl;
752 #ifdef SSL_ERROR_WANT_SESS_CACHE_LOOKUP
753  if (!SSL_want_sess_cache_lookup(ssl)) {
754  // libssl.so mismatch
755  std::cerr << "no async support" << std::endl;
756  return nullptr;
757  }
758 
759  AsyncSSLSocket* sslSocket = AsyncSSLSocket::getFromSSL(ssl);
760  assert(sslSocket != nullptr);
761  // Going to simulate an async cache by just running delaying the miss 100ms
762  if (asyncCallbacks_ % 2 == 0) {
763  // This socket is already blocked on lookup, return miss
764  std::cerr << "returning miss" << std::endl;
765  } else {
766  // fresh meat - block it
767  std::cerr << "async lookup" << std::endl;
768  sslSocket->getEventBase()->tryRunAfterDelay(
770  lookupDelay_);
771  *copyflag = SSL_SESSION_CB_WOULD_BLOCK;
772  asyncLookups_++;
773  }
774 #endif
775  return nullptr;
776  }
int bind(NetworkSocket s, const sockaddr *name, socklen_t namelen)
Definition: NetOps.cpp:76
static AsyncSSLSocket * getFromSSL(const SSL *ssl)

Member Data Documentation

uint32_t folly::TestSSLAsyncCacheServer::asyncCallbacks_ = 0
staticprivate

Definition at line 740 of file AsyncSSLSocketTest.h.

uint32_t folly::TestSSLAsyncCacheServer::asyncLookups_ = 0
staticprivate

Definition at line 741 of file AsyncSSLSocketTest.h.

uint32_t folly::TestSSLAsyncCacheServer::lookupDelay_ = 0
staticprivate

Definition at line 742 of file AsyncSSLSocketTest.h.


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