Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bluejekyll committed Nov 29, 2020
1 parent 2a42fa6 commit a516f38
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions crates/async-std-resolver/src/net.rs
Expand Up @@ -28,11 +28,11 @@ impl UdpSocket for AsyncStdUdpSocket {
.map(AsyncStdUdpSocket)
}

async fn recv_from(&mut self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
async fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
self.0.recv_from(buf).await
}

async fn send_to(&mut self, buf: &[u8], target: &SocketAddr) -> io::Result<usize> {
async fn send_to(&self, buf: &[u8], target: &SocketAddr) -> io::Result<usize> {
self.0.send_to(buf, target).await
}
}
Expand Down
9 changes: 6 additions & 3 deletions crates/proto/src/udp/udp_stream.rs
Expand Up @@ -13,7 +13,7 @@ use std::task::{Context, Poll};

use async_trait::async_trait;
use futures_util::stream::Stream;
use futures_util::{future::poll_fn, future::Future, ready, FutureExt, TryFutureExt};
use futures_util::{future::Future, ready, FutureExt, TryFutureExt};
use log::debug;
use rand;
use rand::distributions::{uniform::Uniform, Distribution};
Expand Down Expand Up @@ -232,7 +232,7 @@ impl UdpSocket for tokio::net::UdpSocket {

// TODO: add poll_recv_from and poll_send_to to be more efficient in allocations...
async fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
poll_fn(|cx| {
futures_util::future::poll_fn(|cx| {
let mut buf = tokio::io::ReadBuf::new(buf);
let addr = ready!(tokio::net::UdpSocket::poll_recv_from(self, cx, &mut buf))?;
let len = buf.filled().len();
Expand All @@ -243,7 +243,10 @@ impl UdpSocket for tokio::net::UdpSocket {
}

async fn send_to(&self, buf: &[u8], target: &SocketAddr) -> io::Result<usize> {
poll_fn(|cx| tokio::net::UdpSocket::poll_send_to(self, cx, buf, target)).await
futures_util::future::poll_fn(|cx| {
tokio::net::UdpSocket::poll_send_to(self, cx, buf, target)
})
.await
}
}

Expand Down
10 changes: 3 additions & 7 deletions crates/server/src/server/server_future.rs
Expand Up @@ -213,21 +213,17 @@ impl<T: RequestHandler> ServerFuture<T> {

let ((cert, chain), key) = certificate_and_key;

let spawner = Handle::current();
let handler = self.handler.clone();
debug!("registered tcp: {:?}", listener);

let tls_acceptor = Box::pin(tls_server::new_acceptor(cert, chain, key)?);

// for each incoming request...
let join = spawner.spawn({
let spawner = spawner.clone();

let join = tokio::spawn({
async move {
let mut listener = listener;
let mut incoming = listener.incoming();

while let Some(tcp_stream) = incoming.next().await {
while let Some(tcp_stream) = listener.next().await {
let tcp_stream = match tcp_stream {
Ok(t) => t,
Err(e) => {
Expand All @@ -240,7 +236,7 @@ impl<T: RequestHandler> ServerFuture<T> {
let tls_acceptor = tls_acceptor.clone();

// kick out to a different task immediately, let them do the TLS handshake
spawner.spawn(async move {
tokio::spawn(async move {
let src_addr = tcp_stream.peer_addr().unwrap();
debug!("starting TLS request from: {}", src_addr);

Expand Down
5 changes: 4 additions & 1 deletion tests/integration-tests/tests/client_future_tests.rs
Expand Up @@ -19,9 +19,12 @@ use trust_dns_client::rr::Record;
use trust_dns_client::rr::{DNSClass, Name, RData, RecordSet, RecordType};
use trust_dns_client::tcp::TcpClientStream;
use trust_dns_client::udp::UdpClientStream;
use trust_dns_proto::iocompat::AsyncIoTokioAsStd;
#[cfg(feature = "dnssec")]
use trust_dns_proto::xfer::{DnsExchangeBackground, DnsMultiplexer, DnsStreamHandle};
use trust_dns_proto::{iocompat::AsyncIoTokioAsStd, TokioTime};
#[cfg(all(feature = "dnssec", feature = "sqlite"))]
use trust_dns_proto::TokioTime;

use trust_dns_server::authority::{Authority, Catalog};

use trust_dns_integration::authority::create_example;
Expand Down
6 changes: 2 additions & 4 deletions tests/integration-tests/tests/server_future_tests.rs
Expand Up @@ -159,7 +159,7 @@ fn test_server_www_tls() {
let pkcs12_der = read_file(&format!("{}/tests/test-data/cert.p12", server_path));

// Server address
let mut runtime = Runtime::new().expect("failed to create Tokio Runtime");
let runtime = Runtime::new().expect("failed to create Tokio Runtime");
let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 0));
let tcp_listener = runtime.block_on(TcpListener::bind(&addr)).unwrap();

Expand Down Expand Up @@ -316,8 +316,6 @@ fn server_thread_tls(
}));

while server_continue.load(Ordering::Relaxed) {
io_loop.block_on(
future::lazy(|_| tokio::time::delay_for(Duration::from_millis(10))).flatten(),
);
io_loop.block_on(future::lazy(|_| tokio::time::sleep(Duration::from_millis(10))).flatten());
}
}

0 comments on commit a516f38

Please sign in to comment.