mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 18:33:24 +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,10 +243,20 @@ impl EpollFile {
|
|||||||
// If this entry's file is ready, save it in the output array.
|
// If this entry's file is ready, save it in the output array.
|
||||||
// EPOLLHUP and EPOLLERR should always be reported.
|
// EPOLLHUP and EPOLLERR should always be reported.
|
||||||
let ready_events = entry.poll() & (ep_event.events | IoEvents::HUP | IoEvents::ERR);
|
let ready_events = entry.poll() & (ep_event.events | IoEvents::HUP | IoEvents::ERR);
|
||||||
if !ready_events.is_empty() {
|
// 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));
|
ep_events.push(EpollEvent::new(ready_events, ep_event.user_data));
|
||||||
count_events += 1;
|
count_events += 1;
|
||||||
}
|
|
||||||
|
|
||||||
// If the epoll entry is neither edge-triggered or one-shot, then we should
|
// If the epoll entry is neither edge-triggered or one-shot, then we should
|
||||||
// keep the entry in the ready list.
|
// keep the entry in the ready list.
|
||||||
|
Reference in New Issue
Block a user