From 11e568c886ce1ced558dc638065f938ea3dee973 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 5 Jan 2014 22:16:16 -0800 Subject: Don't wait for a full buffer when reading TCP libnative erroneously would attempt to fill the entire buffer in a call to `read` before returning, when rather it should return immediately because there's not guaranteed to be any data that will ever be received again. Close #11328 --- src/libnative/io/net.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libnative') diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index b26ac141192..adcd21f0ac4 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -275,12 +275,12 @@ impl TcpStream { impl rtio::RtioTcpStream for TcpStream { fn read(&mut self, buf: &mut [u8]) -> IoResult { - let ret = keep_going(buf, |buf, len| { + let ret = retry(|| { unsafe { libc::recv(self.fd, - buf as *mut libc::c_void, - len as wrlen, - 0) as i64 + buf.as_ptr() as *mut libc::c_void, + buf.len() as wrlen, + 0) as libc::c_int } }); if ret == 0 { -- cgit 1.4.1-3-g733a5