Skip to content

Commit

Permalink
Disable all DNS stats and request cloning
Browse files Browse the repository at this point in the history
Signed-off-by: Edu4rdSHL <edu4rdshl@protonmail.com>
  • Loading branch information
Edu4rdSHL committed May 16, 2021
1 parent 31c748d commit 4840190
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 171 deletions.
2 changes: 1 addition & 1 deletion crates/resolver/src/name_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) use self::name_server::mdns_nameserver;
pub use self::name_server::NameServer;
pub use self::name_server_pool::NameServerPool;
use self::name_server_state::NameServerState;
use self::name_server_stats::NameServerStats;
// use self::name_server_stats::NameServerStats;

#[cfg(feature = "tokio-runtime")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio-runtime")))]
Expand Down
74 changes: 37 additions & 37 deletions crates/resolver/src/name_server/name_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use std::cmp::Ordering;
// use std::cmp::Ordering;
use std::fmt::{self, Debug, Formatter};
use std::pin::Pin;
use std::sync::Arc;
Expand All @@ -21,7 +21,7 @@ use proto::xfer::{DnsHandle, DnsRequest, DnsResponse};
use crate::config::Protocol;
use crate::config::{NameServerConfig, ResolverOpts};
use crate::error::ResolveError;
use crate::name_server::{ConnectionProvider, NameServerState, NameServerStats};
use crate::name_server::{ConnectionProvider, NameServerState}; // , NameServerStats};
#[cfg(feature = "tokio-runtime")]
use crate::name_server::{TokioConnection, TokioConnectionProvider, TokioHandle};

Expand All @@ -35,7 +35,7 @@ pub struct NameServer<
options: ResolverOpts,
client: Arc<Mutex<Option<C>>>,
state: Arc<NameServerState>,
stats: Arc<NameServerStats>,
// stats: Arc<NameServerStats>,
conn_provider: P,
}

Expand Down Expand Up @@ -66,7 +66,7 @@ impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> NameSe
options,
client: Arc::new(Mutex::new(None)),
state: Arc::new(NameServerState::init(None)),
stats: Arc::new(NameServerStats::default()),
// stats: Arc::new(NameServerStats::default()),
conn_provider,
}
}
Expand All @@ -83,7 +83,7 @@ impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> NameSe
options,
client: Arc::new(Mutex::new(Some(client))),
state: Arc::new(NameServerState::init(None)),
stats: Arc::new(NameServerStats::default()),
// stats: Arc::new(NameServerStats::default()),
conn_provider,
}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> NameSe
self.state.establish(remote_edns);

// record the success
self.stats.next_success();
// self.stats.next_success();
Ok(response)
}
Err(error) => {
Expand All @@ -164,7 +164,7 @@ impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> NameSe
self.state.fail(Instant::now());

// record the failure
self.stats.next_failure();
// self.stats.next_failure();

// These are connection failures, not lookup failures, that is handled in the resolver layer
Err(error)
Expand Down Expand Up @@ -197,36 +197,36 @@ where
}
}

impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> Ord for NameServer<C, P> {
/// Custom implementation of Ord for NameServer which incorporates the performance of the connection into it's ranking
fn cmp(&self, other: &Self) -> Ordering {
// if they are literally equal, just return
if self == other {
return Ordering::Equal;
}

// otherwise, run our evaluation to determine the next to be returned from the Heap
// this will prefer established connections, we should try other connections after
// some number to make sure that all are used. This is more important for when
// latency is started to be used.
match self.state.cmp(&other.state) {
Ordering::Equal => (),
o => {
return o;
}
}

self.stats.cmp(&other.stats)
}
}

impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> PartialOrd
for NameServer<C, P>
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
// impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> Ord for NameServer<C, P> {
// /// Custom implementation of Ord for NameServer which incorporates the performance of the connection into it's ranking
// // fn cmp(&self, other: &Self) -> Ordering {
// // // if they are literally equal, just return
// // if self == other {
// // return Ordering::Equal;
// // }

// // // otherwise, run our evaluation to determine the next to be returned from the Heap
// // // this will prefer established connections, we should try other connections after
// // // some number to make sure that all are used. This is more important for when
// // // latency is started to be used.
// // match self.state.cmp(&other.state) {
// // Ordering::Equal => (),
// // o => {
// // return o;
// // }
// // }

// // self.stats.cmp(&other.stats)
// // }
// }

// impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> PartialOrd
// for NameServer<C, P>
// {
// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
// Some(self.cmp(other))
// }
// }

impl<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> PartialEq
for NameServer<C, P>
Expand Down
6 changes: 3 additions & 3 deletions crates/resolver/src/name_server/name_server_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ where
conns: Arc<[NameServer<C, P>]>,
request: DnsRequest,
) -> Result<DnsResponse, ResolveError> {
let mut conns: Vec<NameServer<C, P>> = conns.to_vec();
let conns: Vec<NameServer<C, P>> = conns.to_vec();

// select the highest priority connection
// reorder the connections based on current view...
// this reorders the inner set
conns.sort_unstable();
let request_loop = request.clone();
// conns.sort_unstable();
let request_loop = request;

parallel_conn_loop(conns, request_loop, opts).await
}
Expand Down
Loading

0 comments on commit 4840190

Please # to comment.