diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-01-05 22:16:16 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-01-06 00:08:18 -0800 |
| commit | 11e568c886ce1ced558dc638065f938ea3dee973 (patch) | |
| tree | ccb43f4a53a8a4eddd2db174def928e483829727 /src/libnative | |
| parent | a6d3e57dca68fde4effdda3e4ae2887aa535fcd6 (diff) | |
| download | rust-11e568c886ce1ced558dc638065f938ea3dee973.tar.gz rust-11e568c886ce1ced558dc638065f938ea3dee973.zip | |
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
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/net.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<uint> { - 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 { |
