Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/libstd/sys/sgx/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,22 @@ impl TcpStream {
self.inner.inner.read(buf)
}

pub fn read_vectored(&self, buf: &mut [IoVecMut<'_>]) -> io::Result<usize> {
let buf = match buf.get_mut(0) {
Some(buf) => buf,
None => return Ok(0),
};
self.read(buf)
pub fn read_vectored(&self, bufs: &mut [IoVecMut<'_>]) -> io::Result<usize> {
match bufs.iter_mut().find(|b| !b.is_empty()) {
Some(buf) => self.read(buf),
None => Ok(0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? On at least Linux & Windows, read(&mut []) blocks until the fd is ready for reading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can change the default behavior to fall back to an empty buffer read.

}
}

pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
self.inner.inner.write(buf)
}

pub fn write_vectored(&self, buf: &[IoVec<'_>]) -> io::Result<usize> {
let buf = match buf.get(0) {
Some(buf) => buf,
None => return Ok(0),
};
self.write(buf)
pub fn write_vectored(&self, bufs: &[IoVec<'_>]) -> io::Result<usize> {
match bufs.iter().find(|b| !b.is_empty()) {
Some(buf) => self.write(buf),
None => Ok(0),
}
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
Expand Down