]> git.proxmox.com Git - pve-lxc-syscalld.git/commitdiff
reactor stuff
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 30 Oct 2019 10:16:10 +0000 (11:16 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 30 Oct 2019 10:16:10 +0000 (11:16 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/epoll.rs
src/main.rs
src/reactor.rs

index 08c593b3f709990536b25a20c0843c1a4968bfd5..b6576037f5aba61ead4dee49a49266a987f96939 100644 (file)
@@ -1,8 +1,13 @@
+use std::convert::TryFrom;
 use std::io;
+use std::time::Duration;
 use std::os::raw::c_int;
 use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
 
 use crate::tools::Fd;
+use crate::error::io_err_other;
+
+pub type EpollEvent = libc::epoll_event;
 
 pub struct Epoll {
     fd: Fd,
@@ -54,4 +59,16 @@ impl Epoll {
         });
         Ok(())
     }
+
+    pub fn wait(&self, event_buf: &mut [EpollEvent], timeout: Option<Duration>) -> io::Result<usize> {
+        let millis = timeout
+            .map(|t| c_int::try_from(t.as_millis()))
+            .transpose()
+            .map_err(io_err_other)?
+            .unwrap_or(-1);
+        let epfd = self.fd.as_raw_fd();
+        let buf_len = c_int::try_from(event_buf.len()).map_err(io_err_other)?;
+        let rc = c_try!(unsafe { libc::epoll_wait(epfd, event_buf.as_mut_ptr(), buf_len, millis) });
+        Ok(rc as usize)
+    }
 }
index a5b39b18173e6974841d5ac3041081795918339c..fb2dacdcb6de9aca561eba6f99fe2822766e8556 100644 (file)
@@ -11,6 +11,7 @@ pub mod apparmor;
 pub mod capability;
 pub mod client;
 pub mod epoll;
+pub mod error;
 pub mod executor;
 pub mod fork;
 pub mod lxcseccomp;
index 2be8385c81916f77301553cc9d383d716916483e..36af1f9d9a9fda2050badef8e9706653d30a2978 100644 (file)
@@ -35,5 +35,7 @@ impl Reactor {
     fn thread_main(epoll: Arc<Epoll>, removals: mpsc::Receiver<RawFd>) {
         let _ = epoll;
         let _ = removals;
+        loop {
+        }
     }
 }