From c87ea1dea1313ebb87ea488967425f74ece48891 Mon Sep 17 00:00:00 2001 From: strawberry Date: Thu, 25 Apr 2024 00:23:59 -0400 Subject: [PATCH] delete unused `servername_ratelimiter` semaphore now Signed-off-by: strawberry --- src/service/globals/mod.rs | 4 +--- src/service/mod.rs | 9 ++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index a28d2221..31d81141 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -25,7 +25,7 @@ use ruma::{ DeviceId, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, RoomVersionId, ServerName, UserId, }; -use tokio::sync::{broadcast, watch::Receiver, Mutex, RwLock, Semaphore}; +use tokio::sync::{broadcast, watch::Receiver, Mutex, RwLock}; use tracing::{error, info, trace}; use tracing_subscriber::{EnvFilter, Registry}; use url::Url; @@ -57,7 +57,6 @@ pub(crate) struct Service<'a> { pub(crate) bad_event_ratelimiter: Arc>>, pub(crate) bad_signature_ratelimiter: Arc, RateLimitState>>>, pub(crate) bad_query_ratelimiter: Arc>>, - pub(crate) servername_ratelimiter: Arc>>>, pub(crate) sync_receivers: RwLock>, pub(crate) roomid_mutex_insert: RwLock>>>, pub(crate) roomid_mutex_state: RwLock>>>, @@ -161,7 +160,6 @@ impl Service<'_> { bad_event_ratelimiter: Arc::new(RwLock::new(HashMap::new())), bad_signature_ratelimiter: Arc::new(RwLock::new(HashMap::new())), bad_query_ratelimiter: Arc::new(RwLock::new(HashMap::new())), - servername_ratelimiter: Arc::new(RwLock::new(HashMap::new())), roomid_mutex_state: RwLock::new(HashMap::new()), roomid_mutex_insert: RwLock::new(HashMap::new()), roomid_mutex_federation: RwLock::new(HashMap::new()), diff --git a/src/service/mod.rs b/src/service/mod.rs index e530a2bb..6dd7d447 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -211,7 +211,6 @@ impl Services<'_> { .len(); let resolver_overrides_cache = self.globals.resolver.overrides.read().unwrap().len(); let resolver_destinations_cache = self.globals.resolver.destinations.read().await.len(); - let servername_ratelimiter = self.globals.servername_ratelimiter.read().await.len(); let bad_event_ratelimiter = self.globals.bad_event_ratelimiter.read().await.len(); let bad_query_ratelimiter = self.globals.bad_query_ratelimiter.read().await.len(); let bad_signature_ratelimiter = self.globals.bad_signature_ratelimiter.read().await.len(); @@ -226,7 +225,6 @@ lasttimelinecount_cache: {lasttimelinecount_cache} roomid_spacehierarchy_cache: {roomid_spacehierarchy_cache} resolver_overrides_cache: {resolver_overrides_cache} resolver_destinations_cache: {resolver_destinations_cache} -servername_ratelimiter: {servername_ratelimiter} bad_event_ratelimiter: {bad_event_ratelimiter} bad_query_ratelimiter: {bad_query_ratelimiter} bad_signature_ratelimiter: {bad_signature_ratelimiter} @@ -291,15 +289,12 @@ bad_signature_ratelimiter: {bad_signature_ratelimiter} self.globals.resolver.resolver.clear_cache(); } if amount > 8 { - self.globals.servername_ratelimiter.write().await.clear(); - } - if amount > 9 { self.globals.bad_event_ratelimiter.write().await.clear(); } - if amount > 10 { + if amount > 9 { self.globals.bad_query_ratelimiter.write().await.clear(); } - if amount > 11 { + if amount > 10 { self.globals.bad_signature_ratelimiter.write().await.clear(); } }