You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while !self.out_buffer.is_empty(){let len = stream.write(&self.out_buffer)?;self.out_buffer.drain(0..len);}
However the documentation of std::io::Write::write states:
If the return value is Ok(n) then it must be guaranteed that n <= buf.len(). A return value of 0 typically means that the underlying object is no longer able to accept bytes and will likely not be able to in the future as well, or that the buffer provided is empty.
If anything ever returns Ok(0) here, this hangs in an infinite loop. I think 0 len is sometimes returned to signal an unexpected EOF. I think this loop should check for that and probably bubble up an error instead of looping infinitely.
The text was updated successfully, but these errors were encountered:
najamelan
added a commit
to najamelan/ws_stream_tungstenite
that referenced
this issue
Oct 6, 2019
This is a bug. It seems to be harmless since things like TcpStream never actually return Ok(0) on write. Their indicator of "connection closed" is io::Error with ConnectionReset kind. Corrected this anyway. Let me know if it works for you as expected.
Thanks or the quick resolution. The fix looks good. The thing is that tungstenite works on any io::Read/Write, not just TcpStream. I don't intend to use it other than to communicate to browsers, but sometimes people do. Also testing code might not use TcpStream but a mock network stream.
a-miyashita
pushed a commit
to givery-technology/tungstenite-rs
that referenced
this issue
Jul 20, 2023
This method has a loop as:
However the documentation of
std::io::Write::write
states:If anything ever returns
Ok(0)
here, this hangs in an infinite loop. I think0
len is sometimes returned to signal an unexpected EOF. I think this loop should check for that and probably bubble up an error instead of looping infinitely.The text was updated successfully, but these errors were encountered: