dpc / mioco.pre-0.9

Scalable, coroutine-based, asynchronous IO handling library for Rust programming language. (aka MIO COroutines).
Mozilla Public License 2.0
457 stars 30 forks source link

Error handling for TcpStream::connect to non-listening port #131

Closed gnoack closed 8 years ago

gnoack commented 8 years ago

Thanks for your work on Mioco! This has been a breeze to use so far, apart from this little bug. :)

Steps to reproduce:

I would have assumed that TcpStream::connect() should provide a synchronous programming model when invoked from a mioco coroutine. That would be consistent with what synchronous TCP APIs do.

Suspicion:

In the mio library, TcpStream::connect() is first setting the socket into non-blocking mode and then treating the EINPROGRESS error as successful. (src/sys/unix/tcp.rs:38)

Maybe I'm misunderstanding something about the API? Is there another way in which I can detect this scenario in mioco without doing reads and writes on the socket already?

dpc commented 8 years ago

I think this is #42 again. The reason is the simplistic way mioco translates connection to mio connection, yes.

Let me hack on this for a moment...

dpc commented 8 years ago

Please reopen if something is wrong with it! I'm always happy to fix bug reports.

gnoack commented 8 years ago

Awesome, works great! Thanks for the quick bugfix! :)