Verified Commit 879bbf0d authored by jD91mZM2's avatar jD91mZM2
Browse files

Revert "Only send events that were asked for"

This reverts commit 438acd7d.

Apparently the test I wrote passes anyway with the old code.
I assume the kernel is filtering the events out.
parent 438acd7d
......@@ -22,6 +22,8 @@ fn dup(file: &File, buf: &str) -> io::Result<File> {
fn main() -> io::Result<()> {
let server = File::create("chan:hello_world")?;
println!("Testing events...");
nonblock(&server)?;
let mut event_file = File::open("event:")?;
......@@ -35,8 +37,6 @@ fn main() -> io::Result<()> {
time_file.write(&time)?;
time.tv_sec += 2;
time_file.write(&time)?;
time.tv_sec += 1;
time_file.write(&time)?;
const TOKEN_TIMER: usize = 0;
const TOKEN_STREAM: usize = 1;
......@@ -56,8 +56,6 @@ fn main() -> io::Result<()> {
let mut event = syscall::Event::default();
println!("Testing accept events...");
event_file.read(&mut event)?;
assert_eq!(event.data, TOKEN_TIMER);
assert_eq!(event.flags, syscall::EVENT_READ);
......@@ -75,8 +73,6 @@ fn main() -> io::Result<()> {
assert_eq!(event.flags, syscall::EVENT_WRITE);
println!("-> Accept event");
println!("Testing write events...");
let mut stream = dup(&server, "listen")?;
event_file.read(&mut event)?;
......@@ -100,8 +96,6 @@ fn main() -> io::Result<()> {
assert_eq!(event.flags, syscall::EVENT_READ);
println!("-> Timed out");
println!("Testing read events...");
client.write(b"a")?;
let mut buf = [0; 5];
......@@ -136,20 +130,6 @@ fn main() -> io::Result<()> {
assert_eq!(event.data, TOKEN_TIMER);
println!("-> Timed out");
println!("Testing no events...");
event_file.write(&syscall::Event {
id: server.as_raw_fd(),
flags: 0,
data: TOKEN_SERVER
})?;
let _client = File::open("chan:hello_world")?;
event_file.read(&mut event)?;
assert_eq!(event.data, TOKEN_TIMER);
println!("-> Timed out");
println!("Everything tested!");
Ok(())
}
......@@ -73,19 +73,25 @@ pub struct IpcScheme {
impl IpcScheme {
pub fn post_fevents(&mut self, file: &mut File) -> io::Result<()> {
for (id, handle) in &mut self.handles {
if handle.fevent & EVENT_WRITE == EVENT_WRITE {
if let Connection::Open(_) = handle.remote {
// Send writable even for listeners because that's what smolnetd does for TcpListener
if !handle.notified_write {
handle.notified_write = true;
post_fevent(file, *id, EVENT_WRITE)?;
match handle.extra {
Extra::Listener(_) => {
if let Connection::Open(_) = handle.remote {
// Send writable because that's what smolnetd does for TcpListener
if !handle.notified_write {
handle.notified_write = true;
post_fevent(file, *id, EVENT_WRITE)?;
}
} else {
handle.notified_write = false;
}
},
Extra::Client(ref mut client) => {
if let Connection::Open(_) = handle.remote {
if !handle.notified_write {
handle.notified_write = true;
post_fevent(file, *id, EVENT_WRITE)?;
}
}
} else {
handle.notified_write = false;
}
}
if let Extra::Client(ref mut client) = handle.extra {
if handle.fevent & EVENT_READ == EVENT_READ {
if !client.buffer.is_empty() || handle.remote == Connection::Closed {
if !handle.notified_read {
handle.notified_read = true;
......
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