drogue-iot / embedded-tls

An Rust TLS 1.3 implementation for embedded devices.
Apache License 2.0
168 stars 21 forks source link

enhancement(async): Make RecordReaders read fn cancel-safe #143

Closed MathiasKoch closed 1 month ago

MathiasKoch commented 1 month ago

The only downside is that the ensure_contiguous function now needs to move the header as well, so there might be a 5 byte overhead in the required TLS RX buffer size.

Fixes #142

bugadani commented 1 month ago

I can't say I understand this, but as long as the tests pass I'm fine with the changes.

MathiasKoch commented 1 month ago

The short version of what it does is, that prior to this the read pointer in self.decoded was incremented when reading the record header initially, after which we had an await point to read additional data, whereas now we make sure to read all data before incrementing the read pointer.

This mean that if the future is dropped in between the two calls to advance, we will simply just attempt the full record again next time.