From 7b7dcb5a77061cb69d368de263a02b5ad26fbf51 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 04:20:52 +0100 Subject: unify lock logic --- src/swarm/auth.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/swarm/auth.rs') diff --git a/src/swarm/auth.rs b/src/swarm/auth.rs index 31230a5..1bca60d 100644 --- a/src/swarm/auth.rs +++ b/src/swarm/auth.rs @@ -19,6 +19,7 @@ use std::path::Path; use std::sync::Mutex; use std::time::{Duration, Instant}; +use crate::locks::MutexExt; use anyhow::{Context, Result, bail}; use sha2::{Digest, Sha256}; @@ -67,10 +68,7 @@ impl SwarmKey { /// Records a rejected handshake. Returns how many went unlogged since the last log /// line if this one should be logged, None if it should be suppressed. pub(crate) fn note_rejection(&self) -> Option { - let mut rejections = self - .rejections - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()); + let mut rejections = self.rejections.lock_or_recover(); let due = rejections .last_logged .is_none_or(|last| last.elapsed() >= REJECTION_LOG_INTERVAL); -- cgit v1.3.1