Fix the event_monitor when updating host file events
When no events happen, the state of host file events will not be reset, so the event_monitor should always update the state after polling files.
This commit is contained in:
parent
80a27bc0f9
commit
c5c18ccd6d
@ -80,7 +80,7 @@ impl EventMonitor {
|
|||||||
// 4. the time is up.
|
// 4. the time is up.
|
||||||
let num_events = self.do_poll_ocall(&mut timeout)?;
|
let num_events = self.do_poll_ocall(&mut timeout)?;
|
||||||
|
|
||||||
self.update_host_file_events(num_events);
|
self.update_host_file_events();
|
||||||
|
|
||||||
// Poll syscall does not treat timeout as error. So we need
|
// Poll syscall does not treat timeout as error. So we need
|
||||||
// to distinguish the case by ourselves.
|
// to distinguish the case by ourselves.
|
||||||
@ -99,12 +99,11 @@ impl EventMonitor {
|
|||||||
/// their states accordingly.
|
/// their states accordingly.
|
||||||
pub fn poll_host_files(&mut self) {
|
pub fn poll_host_files(&mut self) {
|
||||||
let mut zero_timeout = Some(Duration::from_secs(0));
|
let mut zero_timeout = Some(Duration::from_secs(0));
|
||||||
let num_events = match self.do_poll_ocall(&mut zero_timeout.as_mut()) {
|
if let Err(_) = self.do_poll_ocall(&mut zero_timeout.as_mut()) {
|
||||||
Ok(num_events) => num_events,
|
return;
|
||||||
Err(_) => return,
|
}
|
||||||
};
|
|
||||||
|
|
||||||
self.update_host_file_events(num_events);
|
self.update_host_file_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_poll_ocall(&mut self, timeout: &mut Option<&mut Duration>) -> Result<usize> {
|
fn do_poll_ocall(&mut self, timeout: &mut Option<&mut Duration>) -> Result<usize> {
|
||||||
@ -148,11 +147,7 @@ impl EventMonitor {
|
|||||||
Ok(num_events)
|
Ok(num_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_host_file_events(&self, num_events: usize) {
|
fn update_host_file_events(&self) {
|
||||||
if num_events == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// According to the output pollfds, update the states of the corresponding host files
|
// According to the output pollfds, update the states of the corresponding host files
|
||||||
let output_pollfds = self.ocall_pollfds[..self.ocall_pollfds.len() - 1].iter();
|
let output_pollfds = self.ocall_pollfds[..self.ocall_pollfds.len() - 1].iter();
|
||||||
for (pollfd, (host_file, mask)) in output_pollfds.zip(self.host_files_and_events()) {
|
for (pollfd, (host_file, mask)) in output_pollfds.zip(self.host_files_and_events()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user