Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer ! isManaged()
[folly.git] / folly / io / async / AsyncSocket.cpp
index 7347dc6890279d65b0cd9373ce9b4fe18579d2a9..991b225c13ed57c84ce70471779104039913d4c5 100644 (file)
@@ -861,7 +861,8 @@ bool AsyncSocket::isZeroCopyRequest(WriteFlags flags) {
 void AsyncSocket::adjustZeroCopyFlags(
     folly::IOBuf* buf,
     folly::WriteFlags& flags) {
-  if (zeroCopyEnabled_ && zeroCopyWriteChainThreshold_ && buf) {
+  if (zeroCopyEnabled_ && zeroCopyWriteChainThreshold_ && buf &&
+      buf->isManaged()) {
     if (buf->computeChainDataLength() >= zeroCopyWriteChainThreshold_) {
       flags |= folly::WriteFlags::WRITE_MSG_ZEROCOPY;
     } else {