From 8c1659aefe841ef1b7255eb31d04aa2fed093271 Mon Sep 17 00:00:00 2001 From: monosans Date: Mon, 29 Jun 2026 20:58:31 +0300 Subject: [PATCH] fix: earlier drops --- src/http.rs | 2 ++ src/ipdb.rs | 25 ++++++++++++++----------- src/main.rs | 1 + 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/http.rs b/src/http.rs index c59464c..41d931b 100644 --- a/src/http.rs +++ b/src/http.rs @@ -156,6 +156,7 @@ impl reqwest_middleware::Middleware for RetryMiddleware { attempt, ) { + drop(resp); tokio::time::sleep(delay).await; attempt = attempt.saturating_add(1); continue; @@ -170,6 +171,7 @@ impl reqwest_middleware::Middleware for RetryMiddleware { && let Some(delay) = calculate_retry_timeout(None, attempt) { + drop(err); tokio::time::sleep(delay).await; attempt = attempt.saturating_add(1); continue; diff --git a/src/ipdb.rs b/src/ipdb.rs index d2e2383..ba56ac8 100644 --- a/src/ipdb.rs +++ b/src/ipdb.rs @@ -27,15 +27,15 @@ impl DbType { headers.insert(reqwest::header::IF_NONE_MATCH, etag); } - let response = http_client - .get(self.url()) - .headers(headers) - .timeout(Duration::MAX) - .send() - .await? - .error_for_status()?; + let request = + http_client.get(self.url()).headers(headers).timeout(Duration::MAX); + drop(http_client); - if response.status() == reqwest::StatusCode::NOT_MODIFIED { + let response = request.send().await?.error_for_status()?; + + let status = response.status(); + if status == reqwest::StatusCode::NOT_MODIFIED { + drop(response); tracing::info!( "Latest {} database is already cached at {}", self.name(), @@ -44,11 +44,11 @@ impl DbType { return Ok(()); } - if response.status() != reqwest::StatusCode::OK { + if status != reqwest::StatusCode::OK { return Err(eyre!( "HTTP status error ({}) for url ({})", - response.status(), - response.url() + status, + response.url(), )); } @@ -169,6 +169,9 @@ impl DbType { ))), ); } + drop(response); + #[cfg(feature = "tui")] + drop(tx); writer.flush().await.wrap_err_with(move || { compact_str::format_compact!( diff --git a/src/main.rs b/src/main.rs index ab92922..0d2451a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,6 +161,7 @@ async fn download_ipdb( let asn_task = spawn(ipdb::DbType::Asn, config.asn_enabled()); let geodb_task = spawn(ipdb::DbType::Geo, config.geolocation_enabled()); + drop(spawn); Ok(output::UseIpDb { asn: asn_task.await?, geo: geodb_task.await? }) }