mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 15:35:59 -07:00
Fix socket connection closed not detected (#2587)
This commit is contained in:
@@ -275,6 +275,12 @@ void OTAComponent::handle_() {
|
||||
}
|
||||
ESP_LOGW(TAG, "Error receiving data for update, errno: %d", errno);
|
||||
goto error;
|
||||
} else if (read == 0) {
|
||||
// $ man recv
|
||||
// "When a stream socket peer has performed an orderly shutdown, the return value will
|
||||
// be 0 (the traditional "end-of-file" return)."
|
||||
ESP_LOGW(TAG, "Remote end closed connection");
|
||||
goto error;
|
||||
}
|
||||
|
||||
error_code = backend->write(buf, read);
|
||||
@@ -362,6 +368,9 @@ bool OTAComponent::readall_(uint8_t *buf, size_t len) {
|
||||
}
|
||||
ESP_LOGW(TAG, "Failed to read %d bytes of data, errno: %d", len, errno);
|
||||
return false;
|
||||
} else if (read == 0) {
|
||||
ESP_LOGW(TAG, "Remote closed connection");
|
||||
return false;
|
||||
} else {
|
||||
at += read;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user