Skip to content

Commit

Permalink
Merge branch 'Arceos-monolithic:main' into dev-multicast
Browse files Browse the repository at this point in the history
  • Loading branch information
YXalix authored Apr 27, 2024
2 parents 44a031e + c59d10f commit 7d76b24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ulib/axstarry/src/syscall_fs/ctype/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ impl EpollFile {
let mut ret_events = Vec::new();
loop {
let current_process = current_process();
let fd_table = current_process.fd_manager.fd_table.lock();
for req_event in events.iter() {
let fd_table = current_process.fd_manager.fd_table.lock();
if let Some(file) = &fd_table[req_event.data as usize] {
let mut ret_event_type = EpollEventType::empty();
if file.is_hang_up() {
Expand Down
4 changes: 2 additions & 2 deletions ulib/axstarry/src/syscall_fs/ctype/eventfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ impl FileIO for EventFd {
fn get_status(&self) -> OpenFlags {
let mut status = OpenFlags::RDWR;
if self.flags & EventFdFlag::EFD_NONBLOCK.bits() != 0 {
status &= OpenFlags::NON_BLOCK;
status |= OpenFlags::NON_BLOCK;
}
if self.flags & EventFdFlag::EFD_CLOEXEC.bits() != 0 {
status &= OpenFlags::CLOEXEC;
status |= OpenFlags::CLOEXEC;
}

status
Expand Down
16 changes: 9 additions & 7 deletions ulib/axstarry/src/syscall_fs/imp/epoll.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The epoll API performs a similar task to poll: monitoring
//! multiple file descriptors to see if I/O is possible on any of
//! them.
//! them.
extern crate alloc;
use crate::{SyscallError, SyscallResult};
use alloc::sync::Arc;
Expand Down Expand Up @@ -100,15 +100,17 @@ pub fn syscall_epoll_wait(args: [usize; 6]) -> SyscallResult {
return Err(SyscallError::EFAULT);
}

let fd_table = process.fd_manager.fd_table.lock();
let epoll_file = if let Some(file) = fd_table[epfd as usize].as_ref() {
if let Some(epoll_file) = file.as_any().downcast_ref::<EpollFile>() {
epoll_file.clone()
let epoll_file = {
let fd_table = process.fd_manager.fd_table.lock();
if let Some(file) = fd_table[epfd as usize].as_ref() {
if let Some(epoll_file) = file.as_any().downcast_ref::<EpollFile>() {
epoll_file.clone()
} else {
return Err(SyscallError::EBADF);
}
} else {
return Err(SyscallError::EBADF);
}
} else {
return Err(SyscallError::EBADF);
};

let timeout = if timeout > 0 {
Expand Down

0 comments on commit 7d76b24

Please sign in to comment.