fix(conn): always flush io from poll_complete

Closes #1108
This commit is contained in:
Sean McArthur
2017-04-03 10:06:39 -07:00
parent d63b7de44f
commit 997a64d770
3 changed files with 12 additions and 2 deletions

View File

@@ -827,6 +827,7 @@ mod tests {
assert!(conn.state.writing.is_queued());
assert!(conn.poll_complete().unwrap().is_ready());
assert!(!conn.state.writing.is_queued());
assert!(conn.io.io_mut().flushed());
Ok(())
}).wait();

View File

@@ -134,15 +134,16 @@ impl<T: Write> Write for Buffered<T> {
fn flush(&mut self) -> io::Result<()> {
if self.write_buf.remaining() == 0 {
Ok(())
self.io.flush()
} else {
loop {
let n = try!(self.write_buf.write_into(&mut self.io));
debug!("flushed {} bytes", n);
if self.write_buf.remaining() == 0 {
return Ok(())
break;
}
}
self.io.flush()
}
}
}