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

reader.try_read() blocks forever after reading a few bytes #155

Open SirVer opened 8 years ago

SirVer commented 8 years ago

This is the followup bug for https://github.com/dpc/mioco/issues/154. I was unable to create a minimal repo case, but I will try to give you access to the environment I am seeing this bug.

Background: I am writing a replacement for Widelands's meta server. Think of it as a sort of mini battle.net only for Widelands. The current version is in go, the one before it was in python. I use this to learn new languages and paradigms and I was playing around with mioco.

My current implementation that shows this bug on Mac OS X with latest nightlies is https://github.com/SirVer/mioco_wlms_block. When running it and connecting widelands to it, the last lines I see in the console of the sever are:

#sirver ALIVE src/main.rs:24
#sirver ALIVE src/main.rs:31
#sirver done.
#sirver ALIVE src/protocol.rs:124
#sirver self.buf[..self.unconsumed]: []
#sirver ALIVE src/protocol.rs:131
<here is a very long pause without output, 20 or so seconds>
#sirver Read: size: 23
#sirver ALIVE src/protocol.rs:145

The last lines are printed here. They signify that reader.try_read() blocks when there a few bytes to read, but less than the buffer's size can be read - which I am surprised about.

If you want to reproduce, you can get yourself a download of widelands. On Linux you will find build-18 likely in your package tree (apt-get install widelands will likely work). There are also PPAs available otherwise. Once you have the game, start it once and exit immediately. Then edit ~/.widelands/config and add under [global] the line: metaserver="localhost". Restart the game, choose multiplayer -> internet game at which point the game should try to connect.