Sometimes SendMsgParamsCallback needs to send different ancillary data for different writes, for example when sending FDs over Unix sockets.
Synopsis
Declared in <folly/io/async/AsyncSocket.h>
struct WriteRequestTag;
Description
This opaque type acts as the key to match writeChain calls with getAncillaryData() and corresponding wroteBytes() calls. It wraps IOBuf*, and implements equality, hashing, and ostream writes for debugging.
Important usage notes:
-
Even though
WriteRequestTagnever dereferences the pointer, it is still INCORRECT to use it after the write is over, whether or not theIOBufhad been destructed, because the same pointer could now refer to new, different data that is being written (seegetReleaseIOBufCallbackfor the mechanism). -
Therefore, if you store a
WriteRequestTag, you must remove it whenever a write is complete. This can be done either inWriteCallback::{writeErr,writeSuccess}, or by inheriting fromAsyncSocket::releaseIOBuf, or by adding a new methodSendMsgParamsCallback::onReleaseIOBuf. -
Not all child classes support write tagging. Notably, we removed the
AsyncSSLSocketimplementation since it added complexity and was not used. Breadcrumbs are inbioWrite, or rev hash 95df2ce7c98a. -
The
EmptyDummyconstructor is for tests, or marking empty tags.SendMsgParamsCallbackmethods can also be called with an empty tag if the write is not submitted viawriteChain.
Types
Name |
Description |
Tag type marking an empty tag, used for tests or unsubmitted writes. |
Member Functions
Name |
Description |
|
Constructors |
Check whether the tag is empty. |
|
Compares two tags for equality by wrapped pointer. |
Friends
Name |
Description |
Writes a textual representation of the tag to a stream. |
|
Hash specialization for AsyncSocket::WriteRequestTag. |
Created with MrDocs