g3-ip-locate: bump MSRV to 1.88

This commit is contained in:
Zhang Jingqiang 2025-08-09 19:48:33 +08:00
parent 6bfed41b83
commit c7b64a833b
5 changed files with 24 additions and 26 deletions

3
Cargo.lock generated
View file

@ -1326,7 +1326,7 @@ dependencies = [
[[package]]
name = "g3-ip-locate"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"anyhow",
"g3-geoip-types",
@ -1334,7 +1334,6 @@ dependencies = [
"g3-socket",
"g3-types",
"g3-yaml",
"ip_network",
"ip_network_table",
"log",
"rmpv",

View file

@ -216,7 +216,7 @@ g3-icap-client = { version = "0.4", path = "lib/g3-icap-client" }
g3-imap-proto = { version = "0.3", path = "lib/g3-imap-proto" }
g3-io-ext = { version = "0.9", path = "lib/g3-io-ext" }
g3-io-sys = { version = "0.1", path = "lib/g3-io-sys" }
g3-ip-locate = { version = "0.2", path = "lib/g3-ip-locate" }
g3-ip-locate = { version = "0.3", path = "lib/g3-ip-locate" }
g3-journal = { version = "0.3", path = "lib/g3-journal" }
g3-json = { version = "0.4", path = "lib/g3-json" }
g3-macros = { version = "0.1", path = "lib/g3-macros" }

View file

@ -1,13 +1,13 @@
[package]
name = "g3-ip-locate"
version = "0.2.0"
version = "0.3.0"
license.workspace = true
edition.workspace = true
rust-version.workspace = true
[dependencies]
anyhow.workspace = true
log.workspace = true
ip_network.workspace = true
ip_network_table.workspace = true
tokio = { workspace = true, features = ["sync", "net", "rt"] }
tokio-util = { workspace = true, features = ["time"] }

View file

@ -55,11 +55,11 @@ impl IpLocationCacheRuntime {
let net = location.network_addr();
let location = Arc::new(location);
if let Some(ip) = ip {
if let Some(vec) = self.doing.remove(&ip) {
for req in vec.into_iter() {
let _ = req.notifier.send(location.clone());
}
if let Some(ip) = ip
&& let Some(vec) = self.doing.remove(&ip)
{
for req in vec.into_iter() {
let _ = req.notifier.send(location.clone());
}
}
@ -73,11 +73,11 @@ impl IpLocationCacheRuntime {
);
} else if let Some(ip) = ip {
// if no new value found, just use the old expired value
if let Some((_net, v)) = self.cache.longest_match(ip) {
if let Some(vec) = self.doing.remove(&ip) {
for req in vec.into_iter() {
let _ = req.notifier.send(v.location.clone());
}
if let Some((_net, v)) = self.cache.longest_match(ip)
&& let Some(vec) = self.doing.remove(&ip)
{
for req in vec.into_iter() {
let _ = req.notifier.send(v.location.clone());
}
}
}
@ -91,11 +91,11 @@ impl IpLocationCacheRuntime {
}
fn handle_req(&mut self, req: CacheQueryRequest) {
if let Some((_net, v)) = self.cache.longest_match(req.ip) {
if v.valid_before >= Instant::now() {
let _ = req.notifier.send(v.location.clone());
return;
}
if let Some((_net, v)) = self.cache.longest_match(req.ip)
&& v.valid_before >= Instant::now()
{
let _ = req.notifier.send(v.location.clone());
return;
}
match self.doing.entry(req.ip) {

View file

@ -98,12 +98,11 @@ impl IpLocationQueryHandle {
data: IpLocationCacheResponse,
expired: bool,
) {
if let Some(ip) = ip {
if let Some(timeout_key) = self.doing_cache.remove(&ip) {
if !expired {
self.doing_timeout_queue.remove(&timeout_key);
}
}
if let Some(ip) = ip
&& let Some(timeout_key) = self.doing_cache.remove(&ip)
&& !expired
{
self.doing_timeout_queue.remove(&timeout_key);
}
let _ = self.rsp_sender.send((ip, data));
}