From 2893fffd20041351f73fd6a8fdb31bf253a88099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 9 Aug 2020 00:44:39 +0200 Subject: [PATCH] aquatic_http: use const LISTENER_TOKEN for clarity --- aquatic_http/src/lib/common.rs | 3 +++ aquatic_http/src/lib/network/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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; }