Rename base loop() to try_drain_overflow_buffer_() inline helper

The base class loop() only drained the overflow buffer. Rename to
make intent clear and inline it so the compiler can optimize across
the call boundary. Make loop() pure virtual since subclasses always
override it.
This commit is contained in:
J. Nick Koston
2026-03-16 12:17:15 -10:00
parent 8a8e05fdb2
commit 7846c42730
4 changed files with 13 additions and 16 deletions
@@ -100,17 +100,6 @@ const LogString *api_error_to_logstr(APIError err) {
return LOG_STR("UNKNOWN");
}
// Default implementation for loop - handles draining overflow buffer
APIError APIFrameHelper::loop() {
if (!this->overflow_buf_.empty() && this->overflow_buf_.try_drain(this->socket_.get()) == -1) {
HELPER_LOG("Socket write failed with errno %d", errno);
if (this->check_socket_write_err_(errno) != APIError::WOULD_BLOCK)
return APIError::SOCKET_WRITE_FAILED;
}
// Convert WOULD_BLOCK to OK to avoid connection termination
return APIError::OK;
}
// This method writes data to socket or buffers it
APIError APIFrameHelper::write_raw_(const struct iovec *iov, int iovcnt, uint16_t total_write_len) {
// Returns APIError::OK if all data was sent or successfully queued.