aquatic_ws: clean up; remove connection on IO error; update TODO

This commit is contained in:
Joakim Frostegård 2020-05-11 14:13:14 +02:00
parent e4bb851c10
commit 274799872f
2 changed files with 13 additions and 11 deletions

View file

@ -7,6 +7,8 @@
* test
* torrent state cleaning
* config
* use src as field in addition to peer_id in peer map, since peers have
access to others' peer id's
## aquatic
* mio: set oneshot for epoll and kqueue? otherwise, stop reregistering?

View file

@ -307,17 +307,20 @@ pub fn read_and_forward_in_messages(
break;
},
Err(err) => {
Err(HandshakeError::Failure(err)) => {
dbg!(err);
},
}
},
_ => unreachable!(),
}
} else if let Some(Connection{ stage: ConnectionStage::Established(connection), ..}) = connections.get_mut(&poll_token){
} else if let Some(Connection{
stage: ConnectionStage::Established(peer_connection),
..
}) = connections.get_mut(&poll_token){
println!("conn established");
match connection.ws.read_message(){
match peer_connection.ws.read_message(){
Ok(ws_message) => {
dbg!(ws_message.clone());
@ -327,28 +330,25 @@ pub fn read_and_forward_in_messages(
let meta = ConnectionMeta {
socket_worker_index,
socket_worker_poll_token: poll_token,
peer_socket_addr: connection.peer_socket_addr
peer_socket_addr: peer_connection.peer_socket_addr
};
in_message_sender.send((meta, in_message));
}
connection.valid_until = valid_until;
peer_connection.valid_until = valid_until;
},
Err(tungstenite::Error::Io(err)) => {
if err.kind() == ErrorKind::WouldBlock {
break
}
remove_connection_if_exists(poll, connections, poll_token);
eprint!("{}", err);
},
Err(tungstenite::Error::ConnectionClosed) => {
// FIXME: necessary?
poll.registry()
.deregister(connection.ws.get_mut())
.unwrap();
connections.remove(&poll_token);
remove_connection_if_exists(poll, connections, poll_token);
},
Err(err) => {
eprint!("{}", err);