Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer ! isManaged()
authorDan Melnic <dmm@fb.com>
Tue, 17 Oct 2017 23:27:56 +0000 (16:27 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 17 Oct 2017 23:30:22 +0000 (16:30 -0700)
Summary: Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer isShared()

Reviewed By: yfeldblum

Differential Revision: D6068711

fbshipit-source-id: fff14dcd4fcb20c9dbb60794420845042518922c

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 {