New fevent functionality to prevent missing events

parent 483ee05e
......@@ -52,7 +52,10 @@ impl EventQueue {
event.flags
);
send_flags(RegKey { scheme, number })?;
let flags = sync(RegKey { scheme, number })?;
if flags > 0 {
trigger(scheme, number, flags);
}
}
Ok(events.len())
......@@ -133,7 +136,7 @@ pub fn register(reg_key: RegKey, queue_key: QueueKey, flags: usize) {
}
}
pub fn send_flags(reg_key: RegKey) -> Result<()> {
pub fn sync(reg_key: RegKey) -> Result<usize> {
let mut flags = 0;
{
......@@ -146,21 +149,13 @@ pub fn send_flags(reg_key: RegKey) -> Result<()> {
}
}
let event_id = {
let scheme = {
let schemes = scheme::schemes();
let scheme = schemes.get(reg_key.scheme).ok_or(Error::new(EBADF))?;
Arc::clone(&scheme)
};
scheme.fevent(reg_key.number, flags)?
let scheme = {
let schemes = scheme::schemes();
let scheme = schemes.get(reg_key.scheme).ok_or(Error::new(EBADF))?;
Arc::clone(&scheme)
};
if event_id != reg_key.number {
println!("scheme {} returned event id {} instead of {}", reg_key.scheme.into(), event_id, reg_key.number);
}
Ok(())
scheme.fevent(reg_key.number, flags)
}
pub fn unregister_file(scheme: SchemeId, number: usize) {
......
......@@ -108,7 +108,7 @@ impl Scheme for DebugScheme {
*handles.get(&id).ok_or(Error::new(EBADF))?
};
Ok(id)
Ok(0)
}
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
......
......@@ -88,7 +88,7 @@ impl Scheme for IrqScheme {
}
fn fevent(&self, file: usize, _flags: usize) -> Result<usize> {
Ok(file)
Ok(0)
}
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
......
......@@ -81,7 +81,7 @@ impl Scheme for ITimerScheme {
fn fevent(&self, id: usize, _flags: usize) -> Result<usize> {
let handles = self.handles.read();
handles.get(&id).ok_or(Error::new(EBADF)).and(Ok(id))
handles.get(&id).ok_or(Error::new(EBADF)).and(Ok(0))
}
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
......
......@@ -166,7 +166,7 @@ impl PipeRead {
}
fn fevent(&self, _flags: usize) -> Result<usize> {
Ok(self.event_id)
Ok(0)
}
fn read(&self, buf: &mut [u8]) -> Result<usize> {
......
......@@ -92,7 +92,7 @@ impl Scheme for TimeScheme {
fn fevent(&self, id: usize, _flags: usize) -> Result<usize> {
let handles = self.handles.read();
handles.get(&id).ok_or(Error::new(EBADF)).and(Ok(id))
handles.get(&id).ok_or(Error::new(EBADF)).and(Ok(0))
}
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
......
......@@ -207,7 +207,7 @@ impl UserInner {
}
pub fn fevent(&self, _flags: usize) -> Result<usize> {
Ok(self.handle_id)
Ok(0)
}
pub fn fsync(&self) -> Result<usize> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment