Skip to content

Commit fad6820

Browse files
committed
Reuse global cache keys
1 parent 3e220d0 commit fad6820

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/resolver.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
44
use std::time::Duration;
55

66
use byteorder::{BigEndian, ByteOrder};
7-
use rand::{random, rng, RngExt};
7+
use rand::random;
88
use siphasher::sip128::Hasher128;
99
use tokio::io::{AsyncReadExt, AsyncWriteExt};
1010
use tokio::net::{TcpSocket, UdpSocket};
@@ -312,9 +312,7 @@ pub async fn get_cached_response_or_resolve(
312312
let original_tid = dns::tid(packet);
313313
dns::set_tid(packet, 0);
314314
dns::normalize_qname(packet)?;
315-
// Create a new hasher instance to avoid race conditions
316-
let (sh_k0, sh_k1) = rng().random::<(u64, u64)>();
317-
let mut hasher = siphasher::sip128::SipHasher13::new_with_keys(sh_k0, sh_k1);
315+
let mut hasher = globals.hasher;
318316
hasher.write(packet);
319317
let packet_hash = hasher.finish128().as_u128();
320318
let cached_response = {

0 commit comments

Comments
 (0)