mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
aquatic_ws: clean up; remove connection on IO error; update TODO
This commit is contained in:
parent
e4bb851c10
commit
274799872f
2 changed files with 13 additions and 11 deletions
2
TODO.md
2
TODO.md
|
|
@ -7,6 +7,8 @@
|
||||||
* test
|
* test
|
||||||
* torrent state cleaning
|
* torrent state cleaning
|
||||||
* config
|
* config
|
||||||
|
* use src as field in addition to peer_id in peer map, since peers have
|
||||||
|
access to others' peer id's
|
||||||
|
|
||||||
## aquatic
|
## aquatic
|
||||||
* mio: set oneshot for epoll and kqueue? otherwise, stop reregistering?
|
* mio: set oneshot for epoll and kqueue? otherwise, stop reregistering?
|
||||||
|
|
|
||||||
|
|
@ -307,17 +307,20 @@ pub fn read_and_forward_in_messages(
|
||||||
|
|
||||||
break;
|
break;
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(HandshakeError::Failure(err)) => {
|
||||||
dbg!(err);
|
dbg!(err);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => 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");
|
println!("conn established");
|
||||||
|
|
||||||
match connection.ws.read_message(){
|
match peer_connection.ws.read_message(){
|
||||||
Ok(ws_message) => {
|
Ok(ws_message) => {
|
||||||
dbg!(ws_message.clone());
|
dbg!(ws_message.clone());
|
||||||
|
|
||||||
|
|
@ -327,28 +330,25 @@ pub fn read_and_forward_in_messages(
|
||||||
let meta = ConnectionMeta {
|
let meta = ConnectionMeta {
|
||||||
socket_worker_index,
|
socket_worker_index,
|
||||||
socket_worker_poll_token: poll_token,
|
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));
|
in_message_sender.send((meta, in_message));
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.valid_until = valid_until;
|
peer_connection.valid_until = valid_until;
|
||||||
},
|
},
|
||||||
Err(tungstenite::Error::Io(err)) => {
|
Err(tungstenite::Error::Io(err)) => {
|
||||||
if err.kind() == ErrorKind::WouldBlock {
|
if err.kind() == ErrorKind::WouldBlock {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_connection_if_exists(poll, connections, poll_token);
|
||||||
|
|
||||||
eprint!("{}", err);
|
eprint!("{}", err);
|
||||||
},
|
},
|
||||||
Err(tungstenite::Error::ConnectionClosed) => {
|
Err(tungstenite::Error::ConnectionClosed) => {
|
||||||
// FIXME: necessary?
|
remove_connection_if_exists(poll, connections, poll_token);
|
||||||
poll.registry()
|
|
||||||
.deregister(connection.ws.get_mut())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
connections.remove(&poll_token);
|
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprint!("{}", err);
|
eprint!("{}", err);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue