Commit 5039adc2 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Reset the zerocopyReadDisabled_ flag on callback change

Summary:
We need to reset the zerocopyReadDisabled_ flag every time we switch between read callbacks since some of them might support a mem store. we verify the support again on the next read attempt.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum

Differential Revision: D33957906

fbshipit-source-id: 37a962c6187502e241288ea179f04ca11c4c27b9
parent 8d89ba5c
......@@ -1230,6 +1230,10 @@ void AsyncSocket::setReadCB(ReadCallback* callback) {
DestructorGuard dg(this);
eventBase_->dcheckIsInEventBaseThread();
// This new callback might support zero copy reads, so reset the
// zerocopyReadDisabled_ flag to its default value so we will
// check for support again on the next read attempt.
zerocopyReadDisabled_ = false;
switch ((StateEnum)state_) {
case StateEnum::CONNECTING:
......@@ -2745,14 +2749,14 @@ void AsyncSocket::splitIovecArray(
AsyncSocket::ReadCode AsyncSocket::processZeroCopyRead() {
#if TCP_ZEROCOPY_RECEIVE
if (!zerocopyReadSupported_) {
if (zerocopyReadDisabled_) {
return ReadCode::READ_NOT_SUPPORTED;
}
auto* memStore = readCallback_->readZeroCopyEnabled();
if (!memStore) {
// set zerocopyReadSupported_ to false to avoid further virtual calls
zerocopyReadSupported_ = false;
// set zerocopyReadDisabled_ to true to avoid further virtual calls
zerocopyReadDisabled_ = true;
return ReadCode::READ_NOT_SUPPORTED;
}
......@@ -2842,7 +2846,7 @@ AsyncSocket::ReadCode AsyncSocket::processZeroCopyRead() {
}
// treat any other error as not supported, fall back to regular read
zerocopyReadSupported_ = false;
zerocopyReadDisabled_ = true;
}
#endif
return ReadCode::READ_NOT_SUPPORTED;
......
......@@ -1664,7 +1664,7 @@ class AsyncSocket : public AsyncTransport {
size_t zeroCopyReenableCounter_{0};
// zerocopy read
bool zerocopyReadSupported_{true};
bool zerocopyReadDisabled_{false};
// subclasses may cache these on first call to get
mutable std::unique_ptr<const AsyncTransportCertificate> peerCertData_{
......
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