LowLevelLineTransport is not working
en opened this issue · 3 comments
en commented
HI, I made the following modifications to test LowLevelLineTransport
:
diff --git a/src/lib.rs b/src/lib.rs
index 4a2ed09..14d2202 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -20,16 +20,16 @@ extern crate log;
// would be preferable, but this one exposes the core tokio constructs better and has therefore
// higher educational value.
pub mod low_level_transport;
-// pub use low_level_transport::LowLevelLineTransport as LineTransport;
-// pub use low_level_transport::new_line_transport;
+pub use low_level_transport::LowLevelLineTransport as LineTransport;
+pub use low_level_transport::new_line_transport;
// This is the second implementation of the transport. It uses tokio::io::Framed - which works with
// the concept of a Parser and Serializer and works with higher level abstractions from the bytes
// crate. Its implementation is much simpler and less error prone, and would be the correct choice
// in production code.
-pub mod framed_transport;
-pub use framed_transport::FramedLineTransport as LineTransport;
-pub use framed_transport::new_line_transport;
+// pub mod framed_transport;
+// pub use framed_transport::FramedLineTransport as LineTransport;
+// pub use framed_transport::new_line_transport;
// Contains the definition of the service that is used both by client and server. It also contains
// the function showing how to serve a service up.
read_to_end
reads all the data and returns an error of io::ErrorKind::WouldBlock
.
tokio won't call read
again, just hang there.
carllerche commented
Thanks, I'll take a look.
Deleted user commented
The unconditional exit from FramedIo::read after an error is returned from
read_to_end is the source of problem. While this is not reflected in the return
type, the read_to_end might in fact have successfully read some data and in
this case it should reparse it (at least in WouldBlock case).
Otherwise if no more data is forthcoming, the read will not be called again and
client will be stuck.
carllerche commented
I simplified tokio-line to only have a simple transport :)