proxygen
|
#include <LocalTransport.h>
Public Types | |
using | UniquePtr = std::unique_ptr< LocalTransport, Destructor > |
Public Types inherited from folly::AsyncTransportWrapper | |
using | UniquePtr = std::unique_ptr< AsyncTransportWrapper, Destructor > |
using | ReadCallback = AsyncReader::ReadCallback |
using | WriteCallback = AsyncWriter::WriteCallback |
Public Types inherited from folly::AsyncTransport | |
typedef std::unique_ptr< AsyncTransport, Destructor > | UniquePtr |
Public Member Functions | |
void | setTrickle (bool trickle, folly::Function< void()> callback=nullptr) |
void | setPeer (LocalTransport *peer) |
void | receiveData (std::unique_ptr< folly::IOBuf > buf) |
ReadCallback * | getReadCallback () const override |
void | setReadCB (ReadCallback *callback) override |
void | write (WriteCallback *, const void *, size_t, folly::WriteFlags=folly::WriteFlags::NONE) override |
void | writeChain (WriteCallback *callback, std::unique_ptr< folly::IOBuf > &&buf, folly::WriteFlags=folly::WriteFlags::NONE) override |
void | writev (WriteCallback *, const iovec *, size_t, folly::WriteFlags=folly::WriteFlags::NONE) override |
folly::EventBase * | getEventBase () const override |
void | attachEventBase (folly::EventBase *eventBase) override |
void | close () override |
void | closeNow () override |
void | closeWithReset () override |
bool | connecting () const override |
void | detachEventBase () override |
bool | error () const override |
size_t | getAppBytesReceived () const override |
size_t | getAppBytesWritten () const override |
void | getLocalAddress (folly::SocketAddress *) const override |
void | getPeerAddress (folly::SocketAddress *) const override |
size_t | getRawBytesReceived () const override |
size_t | getRawBytesWritten () const override |
uint32_t | getSendTimeout () const override |
bool | good () const override |
bool | isDetachable () const override |
bool | isEorTrackingEnabled () const override |
bool | readable () const override |
void | setEorTracking (bool) override |
void | setSendTimeout (uint32_t) override |
void | shutdownWrite () override |
void | shutdownWriteNow () override |
Public Member Functions inherited from folly::AsyncTransportWrapper | |
virtual const AsyncTransportWrapper * | getWrappedTransport () const |
template<class T > | |
const T * | getUnderlyingTransport () const |
template<class T > | |
T * | getUnderlyingTransport () |
Public Member Functions inherited from folly::AsyncTransport | |
virtual bool | writable () const |
virtual bool | isPending () const |
SocketAddress | getLocalAddress () const |
void | getAddress (SocketAddress *address) const override |
SocketAddress | getPeerAddress () const |
virtual ssl::X509UniquePtr | getPeerCert () const |
virtual const X509 * | getSelfCert () const |
virtual const AsyncTransportCertificate * | getPeerCertificate () const |
virtual const AsyncTransportCertificate * | getSelfCertificate () const |
virtual std::string | getApplicationProtocol () const noexcept |
virtual std::string | getSecurityProtocol () const |
virtual bool | isReplaySafe () const |
virtual void | setReplaySafetyCallback (ReplaySafetyCallback *callback) |
Public Member Functions inherited from folly::DelayedDestruction | |
virtual void | destroy () |
bool | getDestroyPending () const |
Public Member Functions inherited from folly::DelayedDestructionBase | |
virtual | ~DelayedDestructionBase ()=default |
Public Member Functions inherited from folly::AsyncSocketBase | |
virtual | ~AsyncSocketBase ()=default |
Private Member Functions | |
void | deliverData () |
Private Attributes | |
LocalTransport * | peer_ {nullptr} |
folly::EventBase * | evb_ {nullptr} |
size_t | received_ {0} |
size_t | written_ {0} |
folly::IOBufQueue | readBuf_ {folly::IOBufQueue::cacheChainLength()} |
ReadCallback * | callback_ {nullptr} |
bool | trickle_ {false} |
folly::Function< void()> | trickleCallback_ |
Additional Inherited Members | |
Protected Member Functions inherited from folly::AsyncTransport | |
~AsyncTransport () override=default | |
Protected Member Functions inherited from folly::DelayedDestruction | |
~DelayedDestruction () override=default | |
DelayedDestruction () | |
Protected Member Functions inherited from folly::DelayedDestructionBase | |
DelayedDestructionBase () | |
uint32_t | getDestructorGuardCount () const |
Protected Member Functions inherited from folly::AsyncReader | |
virtual | ~AsyncReader ()=default |
Protected Member Functions inherited from folly::AsyncWriter | |
virtual | ~AsyncWriter ()=default |
Definition at line 16 of file LocalTransport.h.
using fizz::test::LocalTransport::UniquePtr = std::unique_ptr<LocalTransport, Destructor> |
Definition at line 18 of file LocalTransport.h.
|
inlineoverridevirtual |
Attach the transport to a EventBase.
This may only be called if the transport is not currently attached to a EventBase (by an earlier call to detachEventBase()).
This method must be invoked in the EventBase's thread.
Implements folly::AsyncTransport.
Definition at line 85 of file LocalTransport.h.
References evb_.
|
inlineoverridevirtual |
Close the transport.
This gracefully closes the transport, waiting for all pending write requests to complete before actually closing the underlying transport.
If a read callback is set, readEOF() will be called immediately. If there are outstanding write requests, the close will be delayed until all remaining writes have completed. No new writes may be started after close() has been called.
Implements folly::AsyncTransport.
Definition at line 89 of file LocalTransport.h.
|
inlineoverridevirtual |
Close the transport immediately.
This closes the transport immediately, dropping any outstanding data waiting to be written.
If a read callback is set, readEOF() will be called immediately. If there are outstanding write requests, these requests will be aborted and writeError() will be invoked immediately on all outstanding write callbacks.
Implements folly::AsyncTransport.
Definition at line 91 of file LocalTransport.h.
|
inlineoverridevirtual |
Reset the transport immediately.
This closes the transport immediately, sending a reset to the remote peer if possible to indicate abnormal shutdown.
Note that not all subclasses implement this reset functionality: some subclasses may treat reset() the same as closeNow(). Subclasses that use TCP transports should terminate the connection with a TCP reset.
Reimplemented from folly::AsyncTransport.
Definition at line 93 of file LocalTransport.h.
|
inlineoverridevirtual |
Determine if transport is connected to the endpoint
Implements folly::AsyncTransport.
Definition at line 95 of file LocalTransport.h.
|
inlineprivate |
Definition at line 156 of file LocalTransport.h.
References callback_, folly::IOBufQueue::empty(), folly::IOBufQueue::move(), readBuf_, folly::AsyncReader::ReadCallback::readBufferAvailable(), folly::IOBufQueue::split(), trickle_, and trickleCallback_.
Referenced by receiveData(), and setReadCB().
|
inlineoverridevirtual |
Detach the transport from its EventBase.
This may only be called when the transport is idle and has no reads or writes pending. Once detached, the transport may not be used again until it is re-attached to a EventBase by calling attachEventBase().
This method must be called from the current EventBase's thread.
Implements folly::AsyncTransport.
Definition at line 99 of file LocalTransport.h.
References evb_.
|
inlineoverridevirtual |
Determine if an error has occurred with this transport.
Implements folly::AsyncTransport.
Definition at line 103 of file LocalTransport.h.
|
inlineoverridevirtual |
Implements folly::AsyncTransport.
Definition at line 107 of file LocalTransport.h.
References received_.
|
inlineoverridevirtual |
Implements folly::AsyncTransport.
Definition at line 111 of file LocalTransport.h.
References written_.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Get the address of the local endpoint of this transport.
This function may throw AsyncSocketException on error.
address | The local address will be stored in the specified SocketAddress. |
Implements folly::AsyncTransport.
Definition at line 115 of file LocalTransport.h.
|
inlineoverridevirtual |
Get the address of the remote endpoint to which this transport is connected.
This function may throw AsyncSocketException on error.
address | The remote endpoint's address will be stored in the specified SocketAddress. |
Implements folly::AsyncTransport.
Definition at line 117 of file LocalTransport.h.
|
inlineoverridevirtual |
Implements folly::AsyncTransport.
Definition at line 119 of file LocalTransport.h.
References received_.
|
inlineoverridevirtual |
Implements folly::AsyncTransport.
Definition at line 123 of file LocalTransport.h.
References written_.
|
inlineoverridevirtual |
Implements folly::AsyncTransportWrapper.
Definition at line 42 of file LocalTransport.h.
References callback_.
|
inlineoverridevirtual |
Get the send timeout.
Implements folly::AsyncTransport.
Definition at line 127 of file LocalTransport.h.
|
inlineoverridevirtual |
Determine if transport is open and ready to read or write.
Note that this function returns false on EOF; you must also call error() to distinguish between an EOF and an error.
Implements folly::AsyncTransport.
Definition at line 131 of file LocalTransport.h.
|
inlineoverridevirtual |
Determine if the transport can be detached.
This method must be called from the current EventBase's thread.
Implements folly::AsyncTransport.
Definition at line 135 of file LocalTransport.h.
|
inlineoverridevirtual |
Implements folly::AsyncTransport.
Definition at line 139 of file LocalTransport.h.
|
inlineoverridevirtual |
Determine if the transport is readable or not.
Implements folly::AsyncTransport.
Definition at line 143 of file LocalTransport.h.
|
inline |
Definition at line 36 of file LocalTransport.h.
References folly::IOBufQueue::append(), folly::IOBuf::computeChainDataLength(), deliverData(), folly::gen::move, readBuf_, and received_.
Referenced by writeChain().
|
inlineoverridevirtual |
|
inline |
|
inlineoverridevirtual |
Implements folly::AsyncTransportWrapper.
Definition at line 46 of file LocalTransport.h.
References callback_, deliverData(), and folly::AsyncReader::ReadCallback::isBufferMovable().
|
inlineoverridevirtual |
Set the send timeout.
If write requests do not make any progress for more than the specified number of milliseconds, fail all pending writes and close the transport.
If write requests are currently pending when setSendTimeout() is called, the timeout interval is immediately restarted using the new value.
milliseconds | The timeout duration, in milliseconds. If 0, no timeout will be used. |
Implements folly::AsyncTransport.
Definition at line 149 of file LocalTransport.h.
|
inline |
Deliver the data one byte at a time. Callback will be invoked before delivering each byte.
Note that this does not affect how data within encrypted records is delivered after decryption.
Definition at line 27 of file LocalTransport.h.
References folly::gen::move, trickle_, and trickleCallback_.
|
inlineoverridevirtual |
Perform a half-shutdown of the write side of the transport.
The caller should not make any more calls to write() or writev() after shutdownWrite() is called. Any future write attempts will fail immediately.
Not all transport types support half-shutdown. If the underlying transport does not support half-shutdown, it will fully shutdown both the read and write sides of the transport. (Fully shutting down the socket is better than doing nothing at all, since the caller may rely on the shutdownWrite() call to notify the other end of the connection that no more data can be read.)
If there is pending data still waiting to be written on the transport, the actual shutdown will be delayed until the pending data has been written.
Note: There is no corresponding shutdownRead() equivalent. Simply uninstall the read callback if you wish to stop reading. (On TCP sockets at least, shutting down the read side of the socket is a no-op anyway.)
Implements folly::AsyncTransport.
Definition at line 151 of file LocalTransport.h.
|
inlineoverridevirtual |
Perform a half-shutdown of the write side of the transport.
shutdownWriteNow() is identical to shutdownWrite(), except that it immediately performs the shutdown, rather than waiting for pending writes to complete. Any pending write requests will be immediately failed when shutdownWriteNow() is called.
Implements folly::AsyncTransport.
Definition at line 153 of file LocalTransport.h.
|
inlineoverridevirtual |
If you supply a non-null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation.
Implements folly::AsyncTransportWrapper.
Definition at line 54 of file LocalTransport.h.
References folly::FATAL.
|
inlineoverridevirtual |
If you supply a non-null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation.
Implements folly::AsyncTransportWrapper.
Definition at line 62 of file LocalTransport.h.
References folly::gen::move, peer_, receiveData(), folly::AsyncWriter::WriteCallback::writeSuccess(), and written_.
|
inlineoverridevirtual |
If you supply a non-null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation.
Implements folly::AsyncTransportWrapper.
Definition at line 73 of file LocalTransport.h.
References folly::FATAL.
|
private |
Definition at line 174 of file LocalTransport.h.
Referenced by deliverData(), getReadCallback(), and setReadCB().
|
private |
Definition at line 170 of file LocalTransport.h.
Referenced by attachEventBase(), detachEventBase(), and getEventBase().
|
private |
Definition at line 169 of file LocalTransport.h.
Referenced by setPeer(), and writeChain().
|
private |
Definition at line 173 of file LocalTransport.h.
Referenced by deliverData(), and receiveData().
|
private |
Definition at line 171 of file LocalTransport.h.
Referenced by getAppBytesReceived(), getRawBytesReceived(), and receiveData().
|
private |
Definition at line 176 of file LocalTransport.h.
Referenced by deliverData(), and setTrickle().
|
private |
Definition at line 177 of file LocalTransport.h.
Referenced by deliverData(), and setTrickle().
|
private |
Definition at line 172 of file LocalTransport.h.
Referenced by getAppBytesWritten(), getRawBytesWritten(), and writeChain().