Commit 0ff36eaf authored by Tristan Rice's avatar Tristan Rice Committed by Facebook GitHub Bot

folly: disable zero copy in AsyncSSLSocket to avoid memory leak

Summary: When zero copy is enabled on AsyncSSLSocket every IOBuf written via writeChain is accumulated in idZeroCopyBufInfoMap_ and never freed.

Differential Revision: D22272411

fbshipit-source-id: 576d16ddb4e5c7c19209b77f7346949f10fbf32d
parent 7e6a92c1
......@@ -805,6 +805,11 @@ class AsyncSSLSocket : public AsyncSocket {
asyncOperationFinishCallback_ = std::move(cb);
}
// zero copy is not supported by openssl.
bool setZeroCopy(bool /*enable*/) override {
return false;
}
private:
/**
* Handle the return from invoking SSL_accept
......
......@@ -213,6 +213,20 @@ TEST(AsyncSSLSocketTest, ConnectWriteReadClose) {
EXPECT_EQ(socket->getSSLSocket()->getTotalConnectTimeout().count(), 10000);
}
/**
* Check that zero copy options are a noop under AsyncSSLSocket since they
* aren't supported.
*/
TEST(AsyncSSLSocketTest, ZeroCopy) {
// Set up SSL context.
std::shared_ptr<SSLContext> sslContext(new SSLContext());
sslContext->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
auto socket = AsyncSSLSocket::newSocket(sslContext, /*evb=*/nullptr);
EXPECT_FALSE(socket->setZeroCopy(true));
EXPECT_FALSE(socket->getZeroCopy());
}
/**
* Same as above simple test, but with a large read len to test
* clamping behavior.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment