Commit 5009c3cb authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Small simplification of AsyncSocket read loop

Summary: [Folly] Small simplification of `AsyncSocket` read loop.

Differential Revision: D21514325

fbshipit-source-id: 0af27205b4aa2807a800430e8a2b3dea36356970
parent fca66cf3
......@@ -1998,9 +1998,9 @@ void AsyncSocket::handleRead() noexcept {
// AsyncSocket between threads properly. This will be sufficient to ensure
// that this thread sees the updated eventBase_ variable after
// readDataAvailable() returns.)
uint16_t numReads = 0;
size_t numReads = maxReadsPerEvent_ ? maxReadsPerEvent_ : size_t(-1);
EventBase* originalEventBase = eventBase_;
while (readCallback_ && eventBase_ == originalEventBase) {
while (readCallback_ && eventBase_ == originalEventBase && numReads--) {
// Get the buffer to read into.
void* buf = nullptr;
size_t buflen = 0, offset = 0;
......@@ -2077,14 +2077,11 @@ void AsyncSocket::handleRead() noexcept {
callback->readEOF();
return;
}
if (maxReadsPerEvent_ && (++numReads >= maxReadsPerEvent_)) {
if (readCallback_ != nullptr) {
// We might still have data in the socket.
// (e.g. see comment in AsyncSSLSocket::checkForImmediateRead)
scheduleImmediateRead();
}
return;
}
}
if (readCallback_ != nullptr) {
// We might still have data in the socket.
// (e.g. see comment in AsyncSSLSocket::checkForImmediateRead)
scheduleImmediateRead();
}
}
......
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