Merge pull request #3759 from tannewt/recv_exit

Exit faster on recv when TLS connection closed
This commit is contained in:
Scott Shawcroft 2020-11-25 13:40:52 -08:00 committed by GitHub
commit e7bab9e86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,6 +103,11 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self,
}
if (available > 0) {
status = esp_tls_conn_read(self->tcp, (void*) buf + received, available);
if (status == 0) {
// Reading zero when something is available indicates a closed
// connection. (The available bytes could have been TLS internal.)
break;
}
if (status > 0) {
received += status;
}