From 1c707eda30a9b473db1b02e0aa58480a8d0ef1d0 Mon Sep 17 00:00:00 2001 From: He Sun Date: Thu, 7 May 2020 11:30:55 +0800 Subject: [PATCH] Add support for monitoring epoll fds with epoll --- src/libos/src/net/io_multiplexing/epoll.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libos/src/net/io_multiplexing/epoll.rs b/src/libos/src/net/io_multiplexing/epoll.rs index b035bc9b..1041e771 100644 --- a/src/libos/src/net/io_multiplexing/epoll.rs +++ b/src/libos/src/net/io_multiplexing/epoll.rs @@ -97,6 +97,12 @@ impl EpollFile { socket.fd() } else if let Ok(eventfd) = fd_ref.as_event() { eventfd.get_host_fd() + } else if let Ok(epoll_file) = fd_ref.as_epfile() { + let target_host_fd = epoll_file.get_host_fd(); + if self.host_fd == target_host_fd { + return_errno!(EINVAL, "epfd should not be same as the target fd"); + } + target_host_fd } else { return_errno!(EPERM, "unsupported file type"); } @@ -145,6 +151,10 @@ impl EpollFile { Ok(ret) } + + fn get_host_fd(&self) -> c_int { + self.host_fd + } } impl Drop for EpollFile {