Skip to content

Commit

Permalink
Remove fd_entry lookup on stdin,out,err for wasi::poll_oneoff
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Aug 28, 2019
1 parent 5205ada commit 0776da7
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2267,17 +2267,28 @@ pub fn poll_oneoff(

let fd = match s.event_type {
EventType::Read(__wasi_subscription_fs_readwrite_t { fd }) => {
let fd_entry = wasi_try!(state.fs.get_fd(fd));
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_READ) {
return __WASI_EACCES;
match fd {
__WASI_STDIN_FILENO | __WASI_STDOUT_FILENO | __WASI_STDERR_FILENO => (),
_ => {
let fd_entry = wasi_try!(state.fs.get_fd(fd));
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_READ) {
return __WASI_EACCES;
}
}
}
in_events.push(peb.add(PollEvent::PollIn).build());
Some(fd)
}
EventType::Write(__wasi_subscription_fs_readwrite_t { fd }) => {
let fd_entry = wasi_try!(state.fs.get_fd(fd));
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_WRITE) {
return __WASI_EACCES;
match fd {
__WASI_STDIN_FILENO | __WASI_STDOUT_FILENO | __WASI_STDERR_FILENO => (),
_ => {
let fd_entry = wasi_try!(state.fs.get_fd(fd));

if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_WRITE) {
return __WASI_EACCES;
}
}
}
in_events.push(peb.add(PollEvent::PollOut).build());
Some(fd)
Expand Down

0 comments on commit 0776da7

Please sign in to comment.