#include <folly/io/Cursor.h>
#include <folly/io/IOBuf.h>
#include <folly/portability/OpenSSL.h>
-#include <folly/portability/Unistd.h>
using folly::SocketAddress;
using folly::SSLContext;
using namespace folly::ssl;
using folly::ssl::OpenSSLUtils;
+
// We have one single dummy SSL context so that we can implement attach
// and detach methods in a thread safe fashion without modifying opnessl.
static SSLContext *dummyCtx = nullptr;
int AsyncSSLSocket::bioWrite(BIO* b, const char* in, int inl) {
struct msghdr msg;
struct iovec iov;
- int flags = 0;
AsyncSSLSocket* tsslSock;
iov.iov_base = const_cast<char*>(in);
tsslSock = reinterpret_cast<AsyncSSLSocket*>(appData);
CHECK(tsslSock);
+ WriteFlags flags = WriteFlags::NONE;
if (tsslSock->isEorTrackingEnabled() && tsslSock->minEorRawByteNo_ &&
tsslSock->minEorRawByteNo_ <= BIO_number_written(b) + inl) {
- flags = MSG_EOR;
+ flags |= WriteFlags::EOR;
}
-#ifdef MSG_NOSIGNAL
- flags |= MSG_NOSIGNAL;
-#endif
-
-#ifdef MSG_MORE
if (tsslSock->corkCurrentWrite_) {
- flags |= MSG_MORE;
+ flags |= WriteFlags::CORK;
+ }
+
+ int msg_flags = tsslSock->getSendMsgParamsCB()->getFlags(flags);
+ msg.msg_controllen =
+ tsslSock->getSendMsgParamsCB()->getAncillaryDataSize(flags);
+ CHECK_GE(AsyncSocket::SendMsgParamsCallback::maxAncillaryDataSize,
+ msg.msg_controllen);
+ if (msg.msg_controllen != 0) {
+ msg.msg_control = reinterpret_cast<char*>(alloca(msg.msg_controllen));
+ tsslSock->getSendMsgParamsCB()->getAncillaryData(flags, msg.msg_control);
}
-#endif
auto result = tsslSock->sendSocketMessage(
- OpenSSLUtils::getBioFd(b, nullptr), &msg, flags);
+ OpenSSLUtils::getBioFd(b, nullptr), &msg, msg_flags);
BIO_clear_retry_flags(b);
if (!result.exception && result.writeReturn <= 0) {
if (OpenSSLUtils::getBioShouldRetryWrite(int(result.writeReturn))) {