Skip to content

Commit

Permalink
fix problem of sys_poll
Browse files Browse the repository at this point in the history
  • Loading branch information
wfly1998 committed Aug 20, 2020
1 parent a581e4a commit 55c5446
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions linux-syscall/src/file/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ impl Syscall<'_> {
/// Wait for some event on a file descriptor
pub async fn sys_poll(
&mut self,
ufds: UserInOutPtr<PollFd>,
mut ufds: UserInOutPtr<PollFd>,
nfds: usize,
timeout_msecs: usize,
) -> SysResult {
let polls = ufds.read_array(nfds)?;
let mut polls = ufds.read_array(nfds)?;
info!(
"poll: ufds: {:?}, nfds: {:?}, timeout_msecs: {:#x}",
polls, nfds, timeout_msecs
);
#[must_use = "future does nothing unless polled/`await`-ed"]
struct PollFuture<'a> {
polls: Vec<PollFd>,
polls: &'a mut Vec<PollFd>,
syscall: &'a Syscall<'a>,
}

Expand Down Expand Up @@ -74,15 +74,17 @@ impl Syscall<'_> {
}
}
let future = PollFuture {
polls,
polls: &mut polls,
syscall: self,
};
future.await
let result = future.await;
ufds.write_array(&polls)?;
result
}
}

#[repr(C)]
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct PollFd {
fd: FileDesc,
events: PollEvents,
Expand Down

0 comments on commit 55c5446

Please sign in to comment.