proxygen
folly::BlockingWriteClient Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::BlockingWriteClient:
folly::AsyncSSLSocket::HandshakeCB folly::AsyncWriter::WriteCallback

Public Member Functions

 BlockingWriteClient (AsyncSSLSocket::UniquePtr socket)
 
struct iovec * getIovec () const
 
uint32_t getIovecCount () const
 

Private Member Functions

void handshakeSuc (AsyncSSLSocket *) noexceptoverride
 
void handshakeErr (AsyncSSLSocket *, const AsyncSocketException &ex) noexceptoverride
 
void writeSuccess () noexceptoverride
 
void writeErr (size_t bytesWritten, const AsyncSocketException &ex) noexceptoverride
 
- Private Member Functions inherited from folly::AsyncSSLSocket::HandshakeCB
virtual ~HandshakeCB ()=default
 
virtual bool handshakeVer (AsyncSSLSocket *, bool preverifyOk, X509_STORE_CTX *) noexcept
 
- Private Member Functions inherited from folly::AsyncWriter::WriteCallback
virtual ~WriteCallback ()=default
 

Private Attributes

AsyncSSLSocket::UniquePtr socket_
 
uint32_t bufLen_
 
uint32_t iovCount_
 
std::unique_ptr< uint8_t[]> buf_
 
std::unique_ptr< struct iovec[]> iov_
 

Detailed Description

Definition at line 790 of file AsyncSSLSocketTest.h.

Constructor & Destructor Documentation

folly::BlockingWriteClient::BlockingWriteClient ( AsyncSSLSocket::UniquePtr  socket)
inlineexplicit

Definition at line 793 of file AsyncSSLSocketTest.h.

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

794  : socket_(std::move(socket)), bufLen_(2500), iovCount_(2000) {
795  // Fill buf_
796  buf_ = std::make_unique<uint8_t[]>(bufLen_);
797  for (uint32_t n = 0; n < sizeof(buf_); ++n) {
798  buf_[n] = n % 0xff;
799  }
800 
801  // Initialize iov_
802  iov_ = std::make_unique<struct iovec[]>(iovCount_);
803  for (uint32_t n = 0; n < iovCount_; ++n) {
804  iov_[n].iov_base = buf_.get() + n;
805  if (n & 0x1) {
806  iov_[n].iov_len = n % bufLen_;
807  } else {
808  iov_[n].iov_len = bufLen_ - (n % bufLen_);
809  }
810  }
811 
812  socket_->sslConn(this, std::chrono::milliseconds(100));
813  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< uint8_t[]> buf_
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412
std::unique_ptr< struct iovec[]> iov_
AsyncSSLSocket::UniquePtr socket_

Member Function Documentation

struct iovec* folly::BlockingWriteClient::getIovec ( ) const
inline

Definition at line 815 of file AsyncSSLSocketTest.h.

815  {
816  return iov_.get();
817  }
std::unique_ptr< struct iovec[]> iov_
uint32_t folly::BlockingWriteClient::getIovecCount ( ) const
inline

Definition at line 818 of file AsyncSSLSocketTest.h.

818  {
819  return iovCount_;
820  }
void folly::BlockingWriteClient::handshakeErr ( AsyncSSLSocket sock,
const AsyncSocketException ex 
)
inlineoverrideprivatevirtualnoexcept

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 826 of file AsyncSSLSocketTest.h.

References ADD_FAILURE.

828  {
829  ADD_FAILURE() << "client handshake error: " << ex.what();
830  }
#define ADD_FAILURE()
Definition: gtest.h:1808
void folly::BlockingWriteClient::handshakeSuc ( AsyncSSLSocket sock)
inlineoverrideprivatevirtualnoexcept

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 823 of file AsyncSSLSocketTest.h.

References folly::SendMsgParamsCallbackBase::socket_.

823  {
824  socket_->writev(this, iov_.get(), iovCount_);
825  }
std::unique_ptr< struct iovec[]> iov_
AsyncSSLSocket::UniquePtr socket_
void folly::BlockingWriteClient::writeErr ( size_t  bytesWritten,
const AsyncSocketException ex 
)
inlineoverrideprivatevirtualnoexcept

writeError() will be invoked if an error occurs writing the data.

Parameters
bytesWrittenThe number of bytes that were successfull
exAn exception describing the error that occurred.

Implements folly::AsyncWriter::WriteCallback.

Definition at line 834 of file AsyncSSLSocketTest.h.

References ADD_FAILURE.

836  {
837  ADD_FAILURE() << "client write error after " << bytesWritten
838  << " bytes: " << ex.what();
839  }
#define ADD_FAILURE()
Definition: gtest.h:1808
void folly::BlockingWriteClient::writeSuccess ( )
inlineoverrideprivatevirtualnoexcept

writeSuccess() will be invoked when all of the data has been successfully written.

Note that this mainly signals that the buffer containing the data to write is no longer needed and may be freed or re-used. It does not guarantee that the data has been fully transmitted to the remote endpoint. For example, on socket-based transports, writeSuccess() only indicates that the data has been given to the kernel for eventual transmission.

Implements folly::AsyncWriter::WriteCallback.

Definition at line 831 of file AsyncSSLSocketTest.h.

References folly::SendMsgParamsCallbackBase::socket_.

831  {
832  socket_->close();
833  }
AsyncSSLSocket::UniquePtr socket_

Member Data Documentation

std::unique_ptr<uint8_t[]> folly::BlockingWriteClient::buf_
private

Definition at line 844 of file AsyncSSLSocketTest.h.

uint32_t folly::BlockingWriteClient::bufLen_
private

Definition at line 842 of file AsyncSSLSocketTest.h.

std::unique_ptr<struct iovec[]> folly::BlockingWriteClient::iov_
private

Definition at line 845 of file AsyncSSLSocketTest.h.

uint32_t folly::BlockingWriteClient::iovCount_
private

Definition at line 843 of file AsyncSSLSocketTest.h.

AsyncSSLSocket::UniquePtr folly::BlockingWriteClient::socket_
private

Definition at line 841 of file AsyncSSLSocketTest.h.


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