I've got an issue with std::io::Lines iterator in my project — rust-mpd.
I have two users complaining about the issue, and I'm out of ideas:
https://github.com/kstep/rust-mpd/issues/1
My problem is the following: my mpd is a pure-Rust client library for MPD. MPD protocol is really simple: you open socket and then write commands to it, and read result, linewise, until you meet "OK\n" string, which means "end of reply". Protocol is line oriented: one command per line, one reply unit per line. So I use ReadBuf::lines()
method to get std::io::Lines
iterator, and then read lines and parse them one by one, nothing fancy.
But once in a while Lines::next()
reads whole reply from MPD into its internal buffer and then issues another read()
request, which blocks and never returns, just because MPD already sent everything it wanted to send. So from end user perspective, they request current song info, and the method never returns (well, until connection times out, in which case they get an error).
I tried to debug it with strace and reproduce the bug locally on my laptop, and with my local MPD server, but to no avail. The bug is reproducible for least two users with different setups: one with remote MPD server, but only for this single setup (he tried other variants, like local server etc, but bug wasn't reproduced), and the second user tells he has this bug reproduced with local MPD server. They both both tried to work with MPD via netcat, and it all worked like a charm, the bug is somewhere on rust-mpd side. They also provided network and strace dumps, analyzing which I came to the conclusions I described above.
I'm out of ideas, and ask for help here. I'll try to provide any info you ask me for.
Thank you in advance.