mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 17:03:23 +00:00
Only push back entry if ready_events is not empty
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
6ecb424dfc
commit
28d51a4496
@ -243,11 +243,21 @@ impl EpollFile {
|
||||
// If this entry's file is ready, save it in the output array.
|
||||
// EPOLLHUP and EPOLLERR should always be reported.
|
||||
let ready_events = entry.poll() & (ep_event.events | IoEvents::HUP | IoEvents::ERR);
|
||||
if !ready_events.is_empty() {
|
||||
ep_events.push(EpollEvent::new(ready_events, ep_event.user_data));
|
||||
count_events += 1;
|
||||
// If there are no events, the entry should be removed from the ready list.
|
||||
if ready_events.is_empty() {
|
||||
entry.reset_ready();
|
||||
// For EPOLLONESHOT flag, this entry should also be removed from the interest list
|
||||
if ep_flags.intersects(EpollFlags::ONE_SHOT) {
|
||||
self.del_interest(entry.fd())
|
||||
.expect("this entry should be in the interest list");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Records the events from the ready list
|
||||
ep_events.push(EpollEvent::new(ready_events, ep_event.user_data));
|
||||
count_events += 1;
|
||||
|
||||
// If the epoll entry is neither edge-triggered or one-shot, then we should
|
||||
// keep the entry in the ready list.
|
||||
if !ep_flags.intersects(EpollFlags::ONE_SHOT | EpollFlags::EDGE_TRIGGER) {
|
||||
|
Reference in New Issue
Block a user