diff --git a/TODO.md b/TODO.md index fcb5aa3..2dc446a 100644 --- a/TODO.md +++ b/TODO.md @@ -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 diff --git a/aquatic_http/src/lib/common.rs b/aquatic_http/src/lib/common.rs index b64d30e..e814c36 100644 --- a/aquatic_http/src/lib/common.rs +++ b/aquatic_http/src/lib/common.rs @@ -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 { - pub worker_index: usize, - pub poll_token: usize, + pub response_consumer_id: ConsumerId, + pub connection_id: ConnectionId, pub peer_ip_address: I, } diff --git a/aquatic_http/src/lib/handlers.rs b/aquatic_http/src/lib/handlers.rs index dd2d6ed..d30fe64 100644 --- a/aquatic_http/src/lib/handlers.rs +++ b/aquatic_http/src/lib/handlers.rs @@ -97,8 +97,8 @@ async fn handle_request_stream( 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( 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, };