From afe23168299fffa4ce1310da1b0d7f5eda129ee0 Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Sat, 9 Aug 2025 19:55:16 +0800 Subject: [PATCH] g3-resolver: bump MSRV to 1.88 --- Cargo.lock | 2 +- Cargo.toml | 2 +- lib/g3-resolver/Cargo.toml | 7 ++-- lib/g3-resolver/src/runtime.rs | 68 +++++++++++++++++----------------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdeb6f22..b25f6c26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "g3-resolver" -version = "0.8.0" +version = "0.9.0" dependencies = [ "ahash", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index b04f5065..f8acf704 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -223,7 +223,7 @@ g3-macros = { version = "0.1", path = "lib/g3-macros" } g3-msgpack = { version = "0.4", path = "lib/g3-msgpack" } g3-openssl = { version = "0.4", path = "lib/g3-openssl" } g3-redis-client = { version = "0.3", path = "lib/g3-redis-client" } -g3-resolver = { version = "0.8", path = "lib/g3-resolver" } +g3-resolver = { version = "0.9", path = "lib/g3-resolver" } g3-runtime = { version = "0.4", path = "lib/g3-runtime" } g3-slog-types = { version = "0.2", path = "lib/g3-slog-types" } g3-smtp-proto = { version = "0.2", path = "lib/g3-smtp-proto" } diff --git a/lib/g3-resolver/Cargo.toml b/lib/g3-resolver/Cargo.toml index 043bcdd6..f87f83c9 100644 --- a/lib/g3-resolver/Cargo.toml +++ b/lib/g3-resolver/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "g3-resolver" -version = "0.8.0" +version = "0.9.0" license.workspace = true edition.workspace = true +rust-version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,7 +11,7 @@ edition.workspace = true anyhow.workspace = true thiserror.workspace = true tokio = { workspace = true, features = ["rt", "sync", "time", "macros"] } -tokio-util = { workspace = true, features = ["time"]} +tokio-util = { workspace = true, features = ["time"] } log.workspace = true indexmap.workspace = true ahash.workspace = true @@ -18,7 +19,7 @@ c-ares = { workspace = true, optional = true, features = ["build-cmake"] } c-ares-resolver = { workspace = true, optional = true } c-ares-sys = { workspace = true, optional = true } # for DEP_ version check hickory-client = { workspace = true, optional = true } -hickory-proto = { workspace = true, optional = true, features = ["tokio"] } +hickory-proto = { workspace = true, optional = true, features = ["tokio"] } rustls = { workspace = true, optional = true } rustls-pki-types = { workspace = true, optional = true } flume = { workspace = true, optional = true, features = ["async"] } diff --git a/lib/g3-resolver/src/runtime.rs b/lib/g3-resolver/src/runtime.rs index 9e8d3974..502f8d5b 100644 --- a/lib/g3-resolver/src/runtime.rs +++ b/lib/g3-resolver/src/runtime.rs @@ -146,13 +146,13 @@ impl ResolverRuntime { self.trash_v4.remove(&record.domain); } let record = Arc::new(record); - if let Some(mut vec) = self.doing_v4.remove(&record.domain) { - if let Some(sender) = vec.pop() { - let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Query)); - self.stats.query_a.add_query_cached_n(vec.len()); - for sender in vec.into_iter() { - let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Cache)); - } + if let Some(mut vec) = self.doing_v4.remove(&record.domain) + && let Some(sender) = vec.pop() + { + let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Query)); + self.stats.query_a.add_query_cached_n(vec.len()); + for sender in vec.into_iter() { + let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Cache)); } } if let Some(expire_at) = record.expire { @@ -175,13 +175,13 @@ impl ResolverRuntime { self.trash_v6.remove(&record.domain); } let record = Arc::new(record); - if let Some(mut vec) = self.doing_v6.remove(&record.domain) { - if let Some(sender) = vec.pop() { - let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Query)); - self.stats.query_aaaa.add_query_cached_n(vec.len()); - for sender in vec.into_iter() { - let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Cache)); - } + if let Some(mut vec) = self.doing_v6.remove(&record.domain) + && let Some(sender) = vec.pop() + { + let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Query)); + self.stats.query_aaaa.add_query_cached_n(vec.len()); + for sender in vec.into_iter() { + let _ = sender.send((Arc::clone(&record), ResolvedRecordSource::Cache)); } } if let Some(expire_at) = record.expire { @@ -193,30 +193,30 @@ impl ResolverRuntime { fn handle_expired_v4(&mut self, domain: &str) { trace!("clean expired v4 for domain {domain}"); - if let Some(r) = self.cache_v4.remove(domain) { - if let Some(vanish_at) = r.inner.vanish { - self.trash_v4.insert( - r.inner.domain.clone(), - TrashedRecord { - inner: r.inner, - vanish_at, - }, - ); - } + if let Some(r) = self.cache_v4.remove(domain) + && let Some(vanish_at) = r.inner.vanish + { + self.trash_v4.insert( + r.inner.domain.clone(), + TrashedRecord { + inner: r.inner, + vanish_at, + }, + ); } } fn handle_expired_v6(&mut self, domain: &str) { trace!("clean expired v6 for domain {domain}"); - if let Some(r) = self.cache_v6.remove(domain) { - if let Some(vanish_at) = r.inner.vanish { - self.trash_v6.insert( - r.inner.domain.clone(), - TrashedRecord { - inner: r.inner, - vanish_at, - }, - ); - } + if let Some(r) = self.cache_v6.remove(domain) + && let Some(vanish_at) = r.inner.vanish + { + self.trash_v6.insert( + r.inner.domain.clone(), + TrashedRecord { + inner: r.inner, + vanish_at, + }, + ); } }