Do not poll unrelated files in sys_select

master
Jiajie Chen 6 years ago
parent 58271c7c8a
commit fc60d2cea2

@ -166,6 +166,9 @@ pub fn sys_select(
if fd >= nfds { if fd >= nfds {
continue; continue;
} }
if !err_fds.contains(fd) && !read_fds.contains(fd) && !write_fds.contains(fd) {
continue;
}
let status = file_like.poll()?; let status = file_like.poll()?;
if status.error && err_fds.contains(fd) { if status.error && err_fds.contains(fd) {
err_fds.set(fd); err_fds.set(fd);
@ -1334,6 +1337,7 @@ impl FdSet {
} }
let slice = unsafe { vm.check_write_array(addr, len)? }; let slice = unsafe { vm.check_write_array(addr, len)? };
let bitset: &'static mut BitSlice<LittleEndian, u32> = slice.into(); let bitset: &'static mut BitSlice<LittleEndian, u32> = slice.into();
debug!("bitset {:?}", bitset);
// save the fdset, and clear it // save the fdset, and clear it
use alloc::prelude::ToOwned; use alloc::prelude::ToOwned;
@ -1357,7 +1361,11 @@ impl FdSet {
/// Check to see whether `fd` is in original `FdSet` /// Check to see whether `fd` is in original `FdSet`
/// Fd should be less than nfds /// Fd should be less than nfds
fn contains(&self, fd: usize) -> bool { fn contains(&self, fd: usize) -> bool {
if fd < self.bitset.len() {
self.origin[fd] self.origin[fd]
} else {
false
}
} }
} }

Loading…
Cancel
Save