mirror of
https://github.com/esphome/esphome.git
synced 2026-09-18 18:48:39 +00:00
Propagate drain errors in write_raw_ to preserve original behavior
This commit is contained in:
@@ -128,7 +128,13 @@ APIError APIFrameHelper::write_raw_(const struct iovec *iov, int iovcnt, uint16_
|
||||
|
||||
// If there is already backlogged data, try to drain then queue behind it
|
||||
if (!this->overflow_buf_.empty()) {
|
||||
this->overflow_buf_.try_drain(this->socket_.get());
|
||||
ssize_t ret = this->overflow_buf_.try_drain(this->socket_.get());
|
||||
if (ret == -1) {
|
||||
const int sav_errno = errno;
|
||||
HELPER_LOG("Socket write failed with errno %d", sav_errno);
|
||||
if (this->check_socket_write_err_(sav_errno) != APIError::WOULD_BLOCK)
|
||||
return APIError::SOCKET_WRITE_FAILED;
|
||||
}
|
||||
// If still backlogged, queue new data behind it; otherwise fall through to direct send
|
||||
if (!this->overflow_buf_.empty())
|
||||
return this->enqueue_or_fail_(iov, iovcnt, total_write_len, 0);
|
||||
|
||||
Reference in New Issue
Block a user