diff options
| author | tv <tv@krebsco.de> | 2026-10-26 04:20:52 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 04:20:52 +0100 |
| commit | 2ff446bdb5c5b82b653eac822061aaeb686c3ccc (patch) | |
| tree | 24b34021a6f4f2029c59c7909c5174ad29136a69 /src/swarm/auth.rs | |
| parent | 735b27ad691f768027d6034a3f50efbd68feda89 (diff) | |
unify lock logic
Diffstat (limited to 'src/swarm/auth.rs')
| -rw-r--r-- | src/swarm/auth.rs | 6 |
1 files changed, 2 insertions, 4 deletions
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<u64> { - 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); |
