From c5c18ccd6d950f615feece4c7cb3ca4180780fa4 Mon Sep 17 00:00:00 2001 From: LI Qing Date: Fri, 6 Aug 2021 08:48:28 +0800 Subject: [PATCH] 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. --- .../io_multiplexing/poll_new/event_monitor.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libos/src/net/io_multiplexing/poll_new/event_monitor.rs b/src/libos/src/net/io_multiplexing/poll_new/event_monitor.rs index 360ea913..be06dbdc 100644 --- a/src/libos/src/net/io_multiplexing/poll_new/event_monitor.rs +++ b/src/libos/src/net/io_multiplexing/poll_new/event_monitor.rs @@ -80,7 +80,7 @@ impl EventMonitor { // 4. the time is up. 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 // to distinguish the case by ourselves. @@ -99,12 +99,11 @@ impl EventMonitor { /// their states accordingly. pub fn poll_host_files(&mut self) { let mut zero_timeout = Some(Duration::from_secs(0)); - let num_events = match self.do_poll_ocall(&mut zero_timeout.as_mut()) { - Ok(num_events) => num_events, - Err(_) => return, - }; + if let Err(_) = self.do_poll_ocall(&mut zero_timeout.as_mut()) { + 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 { @@ -148,11 +147,7 @@ impl EventMonitor { Ok(num_events) } - fn update_host_file_events(&self, num_events: usize) { - if num_events == 0 { - return; - } - + fn update_host_file_events(&self) { // 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(); for (pollfd, (host_file, mask)) in output_pollfds.zip(self.host_files_and_events()) {