-
Notifications
You must be signed in to change notification settings - Fork 169
Open
Labels
to-considerFurther consideration is needed whether this should be implementedFurther consideration is needed whether this should be implemented
Description
Overview
Currently, if a read times out in the tokio Stream impl, the partially read data will be lost due to read_exact not being cancel safe. We currently disconnect upstream of this code if a timeout occurs, but if we want to support recovery, we'll need to consider holding read data in a buffer (or in an error variant) for recovery purposes.
monorepo/runtime/src/network/tokio.rs
Lines 37 to 52 in 2fbf479
| impl crate::Stream for Stream { | |
| async fn recv(&mut self, buf: impl Into<StableBuf> + Send) -> Result<StableBuf, Error> { | |
| let mut buf = buf.into(); | |
| if buf.is_empty() { | |
| return Ok(buf); | |
| } | |
| // Time out if we take too long to read | |
| timeout(self.read_timeout, self.stream.read_exact(buf.as_mut())) | |
| .await | |
| .map_err(|_| Error::Timeout)? | |
| .map_err(|_| Error::RecvFailed)?; | |
| Ok(buf) | |
| } | |
| } |
patrick-ogrady
Metadata
Metadata
Assignees
Labels
to-considerFurther consideration is needed whether this should be implementedFurther consideration is needed whether this should be implemented
Type
Projects
Status
Backlog