stratovirt/0007-loop_context-fix-the-bug-that-parked-event-not-remov.patch

52 lines
2.1 KiB
Diff
Raw Normal View History

From 4f51bd38fbc248e045dc1bcebba54c7bc5e4c66b Mon Sep 17 00:00:00 2001
From: zhouli57 <zhouli57@huawei.com>
Date: Tue, 15 Feb 2022 18:06:29 +0800
Subject: [PATCH 02/10] loop_context: fix the bug that parked event not remove
from events_map
Signed-off-by: zhouli57 <zhouli57@huawei.com>
---
util/src/loop_context.rs | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/util/src/loop_context.rs b/util/src/loop_context.rs
index 9ac8ed7..2c9c8c0 100644
--- a/util/src/loop_context.rs
+++ b/util/src/loop_context.rs
@@ -222,20 +222,20 @@ impl EventLoopContext {
let mut events_map = self.events.write().unwrap();
match events_map.get_mut(&event.raw_fd) {
Some(notifier) => {
- if let EventStatus::Parked = notifier.status {
- return Ok(());
- }
-
- if let Err(error) = self.epoll.ctl(
- ControlOperation::Delete,
- notifier.raw_fd,
- EpollEvent::default(),
- ) {
- let error_num = error.raw_os_error().unwrap();
- if error_num != libc::EBADF && error_num != libc::ENOENT {
- return Err(ErrorKind::BadSyscall(error).into());
+ if let EventStatus::Alive = notifier.status {
+ // No need to delete fd if status is Parked, it's done in park_event.
+ if let Err(error) = self.epoll.ctl(
+ ControlOperation::Delete,
+ notifier.raw_fd,
+ EpollEvent::default(),
+ ) {
+ let error_num = error.raw_os_error().unwrap();
+ if error_num != libc::EBADF && error_num != libc::ENOENT {
+ return Err(ErrorKind::BadSyscall(error).into());
+ }
}
}
+
notifier.status = EventStatus::Removed;
if let Some(parked_fd) = notifier.parked_fd {
--
2.25.1