diff --git a/Common/Net/Sinks.cpp b/Common/Net/Sinks.cpp index 4fbfadfbd6..7598780304 100644 --- a/Common/Net/Sinks.cpp +++ b/Common/Net/Sinks.cpp @@ -191,7 +191,20 @@ void InputSink::Fill() { size_t avail = BUFFER_SIZE - std::max(write_, valid_); int bytes = recv(fd_, buf_ + write_, avail, MSG_NOSIGNAL); - AccountFill(bytes); + if (bytes < 0) { + int err = socket_errno; + if (err == EWOULDBLOCK || err == EAGAIN) + return; + ERROR_LOG(Log::Net, "Error reading from socket: %d", err); + return; + } + + // Okay, move forward (might be by zero.) + valid_ += bytes; + write_ += bytes; + if (write_ >= BUFFER_SIZE) { + write_ -= BUFFER_SIZE; + } } } @@ -204,23 +217,6 @@ bool InputSink::Block() { return true; } -void InputSink::AccountFill(int bytes) { - if (bytes < 0) { - int err = socket_errno; - if (err == EWOULDBLOCK || err == EAGAIN) - return; - ERROR_LOG(Log::Net, "Error reading from socket: %d", err); - return; - } - - // Okay, move forward (might be by zero.) - valid_ += bytes; - write_ += bytes; - if (write_ >= BUFFER_SIZE) { - write_ -= BUFFER_SIZE; - } -} - void InputSink::AccountDrain(size_t bytes) { valid_ -= bytes; read_ += bytes; diff --git a/Common/Net/Sinks.h b/Common/Net/Sinks.h index 3f8d157252..b25ce09054 100644 --- a/Common/Net/Sinks.h +++ b/Common/Net/Sinks.h @@ -41,7 +41,6 @@ private: std::pair BufferParts() const; void Fill(); bool Block(); - void AccountFill(int bytes); void AccountDrain(size_t bytes); size_t FindNewline() const;