File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ impl<T: ?Sized> embedded_io::ErrorType for FromTokio<T> {
42
42
43
43
impl < T : tokio:: io:: AsyncRead + Unpin + ?Sized > embedded_io_async:: Read for FromTokio < T > {
44
44
async fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > {
45
+ // The current tokio implementation (https://github.com/tokio-rs/tokio/blob/tokio-1.33.0/tokio/src/io/poll_evented.rs#L165)
46
+ // does not consider the case of buf.is_empty() as a special case,
47
+ // which can cause Poll::Pending to be returned at the end of the stream when called with an empty buffer.
48
+ // This poll will, however, never become ready, as no more bytes will be received.
49
+ if buf. is_empty ( ) {
50
+ return Ok ( 0 ) ;
51
+ }
52
+
45
53
poll_fn ( |cx| {
46
54
let mut buf = tokio:: io:: ReadBuf :: new ( buf) ;
47
55
match Pin :: new ( & mut self . inner ) . poll_read ( cx, & mut buf) {
You can’t perform that action at this time.
0 commit comments