1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 15:12:06 +00:00

Fix socket connection closed not detected (#2587)

This commit is contained in:
Otto Winter
2021-10-22 10:46:44 +02:00
committed by GitHub
parent 68c8547067
commit 9220d9fc52
5 changed files with 53 additions and 15 deletions

View File

@@ -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;
}