aquatic_http: improve ConnectionMeta field names and types

This commit is contained in:
Joakim Frostegård 2021-10-28 19:30:04 +02:00
parent 2deadb2fff
commit af0761418e
3 changed files with 13 additions and 13 deletions

View file

@ -1,7 +1,6 @@
# TODO
* aquatic_http glommio:
* get rid of / improve ConnectionMeta stuff in handler
* clean out connections regularly
* timeout inside of task for "it took to long to receive request, send response"?
* handle panicked/cancelled tasks

View file

@ -129,15 +129,16 @@ impl Ip for Ipv6Addr {}
pub struct ConnectionMeta {
/// Index of socket worker responsible for this connection. Required for
/// sending back response through correct channel to correct worker.
pub worker_index: usize, // Or response consumer id in glommio
pub response_consumer_id: ConsumerId,
pub peer_addr: SocketAddr,
pub poll_token: usize, // Or connection id in glommio
/// Connection id local to socket worker
pub connection_id: ConnectionId,
}
#[derive(Clone, Copy, Debug)]
pub struct PeerConnectionMeta<I: Ip> {
pub worker_index: usize,
pub poll_token: usize,
pub response_consumer_id: ConsumerId,
pub connection_id: ConnectionId,
pub peer_ip_address: I,
}

View file

@ -97,8 +97,8 @@ async fn handle_request_stream<S>(
connection_id,
} => {
let meta = ConnectionMeta {
worker_index: response_consumer_id.0,
poll_token: connection_id.0,
response_consumer_id,
connection_id,
peer_addr,
};
@ -126,8 +126,8 @@ async fn handle_request_stream<S>(
connection_id,
} => {
let meta = ConnectionMeta {
worker_index: response_consumer_id.0,
poll_token: connection_id.0,
response_consumer_id,
connection_id,
peer_addr,
};
@ -172,8 +172,8 @@ pub fn handle_announce_request(
torrent_maps.ipv4.entry(request.info_hash).or_default();
let peer_connection_meta = PeerConnectionMeta {
worker_index: meta.worker_index,
poll_token: meta.poll_token,
response_consumer_id: meta.response_consumer_id,
connection_id: meta.connection_id,
peer_ip_address,
};
@ -201,8 +201,8 @@ pub fn handle_announce_request(
torrent_maps.ipv6.entry(request.info_hash).or_default();
let peer_connection_meta = PeerConnectionMeta {
worker_index: meta.worker_index,
poll_token: meta.poll_token,
response_consumer_id: meta.response_consumer_id,
connection_id: meta.connection_id,
peer_ip_address,
};