diff --git a/aquatic_http/src/lib/common.rs b/aquatic_http/src/lib/common.rs index eb3b768..107f3d4 100644 --- a/aquatic_http/src/lib/common.rs +++ b/aquatic_http/src/lib/common.rs @@ -17,6 +17,9 @@ use aquatic_http_protocol::request::Request; use aquatic_http_protocol::response::{Response, ResponsePeer}; +pub const LISTENER_TOKEN: Token = Token(0); + + pub trait Ip: Copy + Eq + ::std::hash::Hash {} impl Ip for Ipv4Addr {} diff --git a/aquatic_http/src/lib/network/mod.rs b/aquatic_http/src/lib/network/mod.rs index 2dc17ad..7f2ee3c 100644 --- a/aquatic_http/src/lib/network/mod.rs +++ b/aquatic_http/src/lib/network/mod.rs @@ -92,7 +92,7 @@ pub fn run_poll_loop( for event in events.iter(){ let token = event.token(); - if token.0 == 0 { + if token == LISTENER_TOKEN { accept_new_streams( &config, &mut listener, @@ -148,7 +148,7 @@ fn accept_new_streams( Ok((mut stream, _)) => { poll_token_counter.0 = poll_token_counter.0.wrapping_add(1); - if poll_token_counter.0 == 0 { + if *poll_token_counter == LISTENER_TOKEN { poll_token_counter.0 = 1; }