mirror of
https://github.com/esphome/esphome.git
synced 2026-10-06 19:06:37 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user