From ec4871278d1f1778cd84958cb3dd27f2d0f73fce Mon Sep 17 00:00:00 2001 From: Yukiteru Lee Date: Tue, 25 Aug 2020 09:22:33 +0800 Subject: [PATCH] fix problem of sys_poll --- kernel/src/syscall/fs.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 32e101f1..a74a4b89 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -116,7 +116,7 @@ impl Syscall<'_> { pub async fn sys_poll( &mut self, - ufds: UserInOutPtr, + mut ufds: UserInOutPtr, nfds: usize, timeout_msecs: usize, ) -> SysResult { @@ -132,7 +132,7 @@ impl Syscall<'_> { // check whether the fds is valid and is owned by this process let condvars = alloc::vec![&(*TICK_ACTIVITY), &(*SOCKET_ACTIVITY)]; - let polls = ufds.read_array(nfds).unwrap(); + let mut polls = ufds.read_array(nfds).unwrap(); if !proc.pid.is_init() { info!("poll: fds: {:?}", polls); @@ -142,7 +142,7 @@ impl Syscall<'_> { #[must_use = "future does nothing unless polled/`await`-ed"] struct PollFuture<'a> { - polls: Vec, + polls: &'a mut Vec, syscall: &'a Syscall<'a>, } @@ -193,10 +193,12 @@ impl Syscall<'_> { } let future = PollFuture { - polls, + polls: &mut polls, syscall: self, }; - future.await + let res = future.await; + ufds.write_array(&polls)?; + res } pub fn sys_pselect6(