proxygen
folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback Class Reference

#include <AsyncSSLSocket.h>

Inheritance diagram for folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback:
folly::ReadCallback folly::ReadCallbackBase folly::AsyncReader::ReadCallback

Public Member Functions

 DefaultOpenSSLAsyncFinishCallback (AsyncPipeReader::UniquePtr reader, AsyncSSLSocket *sslSocket, DestructorGuard dg)
 
 ~DefaultOpenSSLAsyncFinishCallback ()
 
void readDataAvailable (size_t len) noexceptoverride
 
void getReadBuffer (void **bufReturn, size_t *lenReturn) noexceptoverride
 
void readEOF () noexceptoverride
 
void readErr (const folly::AsyncSocketException &) noexceptoverride
 
- Public Member Functions inherited from folly::ReadCallback
 ReadCallback (WriteCallbackBase *wcb)
 
 ~ReadCallback () override
 
void getReadBuffer (void **bufReturn, size_t *lenReturn) override
 
void readDataAvailable (size_t len) noexceptoverride
 
- Public Member Functions inherited from folly::ReadCallbackBase
 ReadCallbackBase (WriteCallbackBase *wcb)
 
 ~ReadCallbackBase () override
 
void setSocket (const std::shared_ptr< AsyncSSLSocket > &socket)
 
void setState (StateEnum s)
 
void readErr (const AsyncSocketException &ex) noexceptoverride
 
void readEOF () noexceptoverride
 
- Public Member Functions inherited from folly::AsyncReader::ReadCallback
virtual bool isBufferMovable () noexcept
 
virtual size_t maxBufferSize () const
 
virtual void readBufferAvailable (std::unique_ptr< IOBuf >) noexcept
 

Private Attributes

uint8_t byte_ {0}
 
AsyncPipeReader::UniquePtr pipeReader_
 
AsyncSSLSocketsslSocket_ {nullptr}
 
DestructorGuard dg_
 

Additional Inherited Members

- Public Attributes inherited from folly::ReadCallback
std::vector< Bufferbuffers
 
Buffer currentBuffer
 
- Public Attributes inherited from folly::ReadCallbackBase
std::shared_ptr< AsyncSSLSocketsocket_
 
WriteCallbackBasewcb_
 
StateEnum state
 

Detailed Description

A class to wait for asynchronous operations with OpenSSL 1.1.0

Definition at line 156 of file AsyncSSLSocket.h.

Constructor & Destructor Documentation

folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::DefaultOpenSSLAsyncFinishCallback ( AsyncPipeReader::UniquePtr  reader,
AsyncSSLSocket sslSocket,
DestructorGuard  dg 
)
inline

Definition at line 158 of file AsyncSSLSocket.h.

162  : pipeReader_(std::move(reader)),
163  sslSocket_(sslSocket),
164  dg_(std::move(dg)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::~DefaultOpenSSLAsyncFinishCallback ( )
inline

Definition at line 166 of file AsyncSSLSocket.h.

References sslSocket_.

166  {
167  pipeReader_->setReadCB(nullptr);
169  }
void setAsyncOperationFinishCallback(std::unique_ptr< ReadCallback > cb)

Member Function Documentation

void folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::getReadBuffer ( void **  bufReturn,
size_t *  lenReturn 
)
inlineoverridevirtualnoexcept

When data becomes available, getReadBuffer() will be invoked to get the buffer into which data should be read.

This method allows the ReadCallback to delay buffer allocation until data becomes available. This allows applications to manage large numbers of idle connections, without having to maintain a separate read buffer for each idle connection.

It is possible that in some cases, getReadBuffer() may be called multiple times before readDataAvailable() is invoked. In this case, the data will be written to the buffer returned from the most recent call to readDataAvailable(). If the previous calls to readDataAvailable() returned different buffers, the ReadCallback is responsible for ensuring that they are not leaked.

If getReadBuffer() throws an exception, returns a nullptr buffer, or returns a 0 length, the ReadCallback will be uninstalled and its readError() method will be invoked.

getReadBuffer() is not allowed to change the transport state before it returns. (For example, it should never uninstall the read callback, or set a different read callback.)

Parameters
bufReturngetReadBuffer() should update *bufReturn to contain the address of the read buffer. This parameter will never be nullptr.
lenReturngetReadBuffer() should update *lenReturn to contain the maximum number of bytes that may be written to the read buffer. This parameter will never be nullptr.

Implements folly::AsyncReader::ReadCallback.

Definition at line 178 of file AsyncSSLSocket.h.

178  {
179  *bufReturn = &byte_;
180  *lenReturn = 1;
181  }
void folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::readDataAvailable ( size_t  len)
inlineoverridevirtualnoexcept

readDataAvailable() will be invoked when data has been successfully read into the buffer returned by the last call to getReadBuffer().

The read callback remains installed after readDataAvailable() returns. It must be explicitly uninstalled to stop receiving read events. getReadBuffer() will be called at least once before each call to readDataAvailable(). getReadBuffer() will also be called before any call to readEOF().

Parameters
lenThe number of bytes placed in the buffer.

Implements folly::AsyncReader::ReadCallback.

Definition at line 171 of file AsyncSSLSocket.h.

References sslSocket_.

171  {
172  CHECK_EQ(len, 1);
174  pipeReader_->setReadCB(nullptr);
176  }
void setAsyncOperationFinishCallback(std::unique_ptr< ReadCallback > cb)
void folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::readEOF ( )
inlineoverridevirtualnoexcept

readEOF() will be invoked when the transport is closed.

The read callback will be automatically uninstalled immediately before readEOF() is invoked.

Implements folly::AsyncReader::ReadCallback.

Definition at line 183 of file AsyncSSLSocket.h.

183 {}
void folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::readErr ( const folly::AsyncSocketException ex)
inlineoverridevirtualnoexcept

readError() will be invoked if an error occurs reading from the transport.

The read callback will be automatically uninstalled immediately before readError() is invoked.

Parameters
exAn exception describing the error that occurred.

Implements folly::AsyncReader::ReadCallback.

Definition at line 185 of file AsyncSSLSocket.h.

185 {}

Member Data Documentation

uint8_t folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::byte_ {0}
private

Definition at line 188 of file AsyncSSLSocket.h.

DestructorGuard folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::dg_
private

Definition at line 191 of file AsyncSSLSocket.h.

AsyncPipeReader::UniquePtr folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::pipeReader_
private

Definition at line 189 of file AsyncSSLSocket.h.

AsyncSSLSocket* folly::AsyncSSLSocket::DefaultOpenSSLAsyncFinishCallback::sslSocket_ {nullptr}
private

Definition at line 190 of file AsyncSSLSocket.h.


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