rust-tuf icon indicating copy to clipboard operation
rust-tuf copied to clipboard

SafeReader doesn't detect stalled transfers

Open wellsie1116 opened this issue 5 years ago • 0 comments

If min_bytes_per_second is non-zero and a transfer is making forward progress but more slowly than required, the stream should error out as expected, however, as poll_read is only expected to be called when more data is available (or the future has otherwise been woken up), if a transfer stalls out completely, nothing will currently wake up the reader for it to detect the stall and produce an error.

It looks like it will need to setup a timer on every call to poll_read that is associated with the Context, but I don't think there is an async cross platform timer crate we could use here yet.

There is also the larger topic of how to test this type without having tests that run longer than 30 seconds (the minimum amount of time before SafeReader enforces a minimum transfer rate) that would be useful to solve too.

wellsie1116 avatar Feb 02 '20 20:02 wellsie1116