From 68d54bdd5d12c622104d2d621e8190827d06145d Mon Sep 17 00:00:00 2001 From: Dan Melnic Date: Tue, 17 Oct 2017 16:27:56 -0700 Subject: [PATCH] Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer ! isManaged() 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/folly/io/async/AsyncSocket.cpp b/folly/io/async/AsyncSocket.cpp index 7347dc68..991b225c 100644 --- a/folly/io/async/AsyncSocket.cpp +++ b/folly/io/async/AsyncSocket.cpp @@ -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 { -- 2.34.1