Added a disconnect for sockets with 3+ spurious wakeups.

This commit is contained in:
Revertron
2021-04-02 15:25:56 +02:00
parent bc0726d3f9
commit db6b96f8dc
2 changed files with 29 additions and 3 deletions
+15 -3
View File
@@ -179,12 +179,24 @@ fn handle_connection_event(context: Arc<Mutex<Context>>, peers: &mut Peers, regi
return false;
}
Some(peer) => {
let mut stream = peer.get_stream();
if event.is_read_closed() {
info!("Spurious wakeup for connection {}, ignoring", token.0);
registry.reregister(stream, token, Interest::READABLE).unwrap();
debug!("Spurious wakeup for connection {}, ignoring", token.0);
if peer.spurious() >= 3 {
debug!("Disconnecting socket on 3 spurious wakeups");
return false;
}
let interest = if let State::Message{..} = peer.get_state() {
Interest::WRITABLE
} else {
Interest::READABLE
};
let stream = peer.get_stream();
registry.reregister(stream, token, interest).unwrap();
peer.inc_spurious();
return true;
}
peer.reset_spurious();
let mut stream = peer.get_stream();
read_message(&mut stream)
}
}