proxygen
folly::WriteErrorCallback Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::WriteErrorCallback:
folly::ReadCallback folly::ReadCallbackBase folly::AsyncReader::ReadCallback

Public Member Functions

 WriteErrorCallback (WriteCallbackBase *wcb)
 
void readDataAvailable (size_t len) noexceptoverride
 
void readErr (const AsyncSocketException &ex) noexceptoverride
 
- Public Member Functions inherited from folly::ReadCallback
 ReadCallback (WriteCallbackBase *wcb)
 
 ~ReadCallback () override
 
void getReadBuffer (void **bufReturn, size_t *lenReturn) override
 
- 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 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
 

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

Definition at line 421 of file AsyncSSLSocketTest.h.

Constructor & Destructor Documentation

folly::WriteErrorCallback::WriteErrorCallback ( WriteCallbackBase wcb)
inlineexplicit

Definition at line 423 of file AsyncSSLSocketTest.h.

423 : ReadCallback(wcb) {}
ReadCallback(WriteCallbackBase *wcb)

Member Function Documentation

void folly::WriteErrorCallback::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.

Reimplemented from folly::ReadCallback.

Definition at line 425 of file AsyncSSLSocketTest.h.

References folly::netops::close(), folly::test::msvcSuppressAbortOnInvalidParams(), folly::SendMsgParamsCallbackBase::socket_, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.

425  {
426  std::cerr << "readDataAvailable, len " << len << std::endl;
427 
428  currentBuffer.length = len;
429 
430  // close the socket before writing to trigger writeError().
431  ::close(socket_->getFd());
432 
434 
435  // Write back the same data.
437  [&] { socket_->write(wcb_, currentBuffer.buffer, len); });
438 
439  if (wcb_->state == STATE_FAILED) {
441  } else {
443  }
444 
445  buffers.push_back(currentBuffer);
447  }
virtual void setSocket(const std::shared_ptr< AsyncSSLSocket > &socket)
std::vector< Buffer > buffers
void setState(StateEnum s)
auto msvcSuppressAbortOnInvalidParams(Func func) -> decltype(func())
Definition: TestUtil.h:166
WriteCallbackBase * wcb_
int close(NetworkSocket s)
Definition: NetOps.cpp:90
std::shared_ptr< AsyncSSLSocket > socket_
state
Definition: http_parser.c:272
void folly::WriteErrorCallback::readErr ( const 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.

Reimplemented from folly::ReadCallbackBase.

Definition at line 449 of file AsyncSSLSocketTest.h.

449  {
450  std::cerr << "readError " << ex.what() << std::endl;
451  // do nothing since this is expected
452  }

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