proxygen
proxygen::HTTPSession::WriteSegment Class Reference
Inheritance diagram for proxygen::HTTPSession::WriteSegment:
folly::AsyncWriter::WriteCallback

Public Member Functions

 WriteSegment (HTTPSession *session, uint64_t length)
 
void setCork (bool cork)
 
void setEOR (bool eor)
 
void detach ()
 
folly::WriteFlags getFlags ()
 
uint64_t getLength () const
 
void writeSuccess () noexceptoverride
 
void writeErr (size_t bytesWritten, const folly::AsyncSocketException &) noexceptoverride
 
- Public Member Functions inherited from folly::AsyncWriter::WriteCallback
virtual ~WriteCallback ()=default
 

Public Attributes

folly::IntrusiveListHook listHook
 

Private Member Functions

void remove ()
 

Private Attributes

HTTPSessionsession_
 
uint64_t length_
 
folly::WriteFlags flags_
 

Detailed Description

Helper class to track write buffers until they have been fully written and can be deleted.

Definition at line 852 of file HTTPSession.h.

Constructor & Destructor Documentation

proxygen::HTTPSession::WriteSegment::WriteSegment ( HTTPSession session,
uint64_t  length 
)

Definition at line 63 of file HTTPSession.cpp.

Referenced by proxygen::HTTPSession::runLoopCallback().

66  : session_(session),
67  length_(length) {
68 }

Member Function Documentation

void proxygen::HTTPSession::WriteSegment::detach ( )

Clear the session. This is used if the session does not want to receive future notification about this segment.

Definition at line 78 of file HTTPSession.cpp.

References session_.

78  {
79  remove();
80  session_ = nullptr;
81 }
folly::WriteFlags proxygen::HTTPSession::WriteSegment::getFlags ( )
inline

Definition at line 879 of file HTTPSession.h.

Referenced by proxygen::HTTPSession::runLoopCallback().

879  {
880  return flags_;
881  }
uint64_t proxygen::HTTPSession::WriteSegment::getLength ( ) const
inline

Definition at line 883 of file HTTPSession.h.

References length_.

883  {
884  return length_;
885  }
void proxygen::HTTPSession::WriteSegment::remove ( )
private

Unlink this segment from the list.

Definition at line 71 of file HTTPSession.cpp.

References listHook, and session_.

71  {
72  DCHECK(session_);
73  DCHECK(listHook.is_linked());
74  listHook.unlink();
75 }
folly::IntrusiveListHook listHook
Definition: HTTPSession.h:893
void proxygen::HTTPSession::WriteSegment::setCork ( bool  cork)
inline

Definition at line 857 of file HTTPSession.h.

References folly::CORK, and folly::unSet().

Referenced by proxygen::HTTPSession::runLoopCallback().

857  {
858  if (cork) {
860  } else {
862  }
863  }
WriteFlags unSet(WriteFlags a, WriteFlags b)
void proxygen::HTTPSession::WriteSegment::setEOR ( bool  eor)
inline

Definition at line 865 of file HTTPSession.h.

References proxygen::HTTPSession::detach(), folly::EOR, and folly::unSet().

Referenced by proxygen::HTTPSession::runLoopCallback().

865  {
866  if (eor) {
868  } else {
870  }
871  }
WriteFlags unSet(WriteFlags a, WriteFlags b)
void proxygen::HTTPSession::WriteSegment::writeErr ( size_t  bytesWritten,
const folly::AsyncSocketException ex 
)
overridevirtualnoexcept

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 102 of file HTTPSession.cpp.

References proxygen::FilterChain< T1, T2, FilterType, set_callback, TakeOwnership >::add(), proxygen::HTTPSessionBase::attachToSessionController(), proxygen::HTTPSession::byteEventTracker_, codec, proxygen::HTTPSessionBase::codec_, proxygen::HTTPSession::draining_, proxygen::HTTPSession::drainTimeout_, proxygen::HTTPSession::flowControlTimeout_, proxygen::HTTPSessionBase::getController(), proxygen::HTTPCodec::getDefaultWindowSize(), proxygen::HTTPCodec::getProtocol(), proxygen::HTTPSession::HTTPSession(), proxygen::HTTPSessionBase::HTTPSessionBase(), proxygen::HTTPSessionBase::infoCallback_, proxygen::HTTPSession::ingressError_, proxygen::HTTPSession::ingressUpgraded_, proxygen::HTTPSession::initialReceiveWindow_, proxygen::HTTPSession::inLoopCallback_, proxygen::HTTPSession::inResume_, proxygen::isHTTP2CodecProtocol(), proxygen::localAddr, proxygen::HTTPSession::maxConcurrentIncomingStreams_, folly::gen::move, proxygen::HTTPSession::nextEgressResults_, proxygen::HTTPSessionBase::InfoCallback::onCreate(), proxygen::HTTPSession::onWriteError(), proxygen::peerAddr, proxygen::HTTPSession::pendingPause_, proxygen::HTTPSession::reads_, proxygen::HTTPSession::receiveSessionWindowSize_, proxygen::HTTPSession::receiveStreamWindowSize_, proxygen::HTTPSession::resetAfterDrainingWrites_, proxygen::HTTPSession::resetSocketOnShutdown_, session_, proxygen::HTTPSession::FlowControlTimeout::setTimeoutDuration(), proxygen::HTTPSession::setupCodec(), proxygen::HTTPSession::sock_, proxygen::HTTPSession::started_, proxygen::HTTPSession::timeout_, proxygen::HTTPSession::txnEgressQueue_, proxygen::HTTPSession::writes_, proxygen::HTTPSession::writesDraining_, and proxygen::HTTPSession::writeTimeout_.

103  {
104  // After one segment fails to write, we clear the session_
105  // pointer in all subsequent write segments, so we ignore their
106  // writeError() callbacks.
107  if (session_) {
108  remove();
109  session_->onWriteError(bytesWritten, ex);
110  }
111  delete this;
112 }
void onWriteError(size_t bytesWritten, const folly::AsyncSocketException &ex)
void proxygen::HTTPSession::WriteSegment::writeSuccess ( )
overridevirtualnoexcept

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 84 of file HTTPSession.cpp.

References length_, proxygen::HTTPSession::onWriteSuccess(), and session_.

84  {
85  // Unlink this write segment from the list before calling
86  // the session's onWriteSuccess() callback because, in the
87  // case where this is the last write for the connection,
88  // onWriteSuccess() looks for an empty write segment list
89  // as one of the criteria for shutting down the connection.
90  remove();
91 
92  // session_ should never be nullptr for a successful write
93  // The session is only cleared after a write error or timeout, and all
94  // AsyncTransport write failures are fatal. If session_ is nullptr at this
95  // point it means the AsyncTransport implementation is not failing
96  // subsequent writes correctly after an error.
98  delete this;
99 }
void onWriteSuccess(uint64_t bytesWritten)

Member Data Documentation

folly::WriteFlags proxygen::HTTPSession::WriteSegment::flags_
private
Initial value:

Definition at line 903 of file HTTPSession.h.

uint64_t proxygen::HTTPSession::WriteSegment::length_
private

Definition at line 902 of file HTTPSession.h.

Referenced by writeSuccess().

folly::IntrusiveListHook proxygen::HTTPSession::WriteSegment::listHook

Definition at line 893 of file HTTPSession.h.

Referenced by remove().

HTTPSession* proxygen::HTTPSession::WriteSegment::session_
private

Definition at line 901 of file HTTPSession.h.

Referenced by detach(), remove(), writeErr(), and writeSuccess().


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