summaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/peers.rs4
-rw-r--r--src/api/stats/prometheus.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs
index a9694f7..fac3440 100644
--- a/src/api/peers.rs
+++ b/src/api/peers.rs
@@ -16,6 +16,7 @@ use utoipa::ToSchema;
use super::store_status;
use crate::document::replica::Epoch;
use crate::document::store;
+use crate::locks::MutexExt;
use crate::state::{AppState, HelloState, Incidents, Liveness, PeerState};
use crate::swarm::peer::forgotten_path;
use crate::transport::traffic::PeerTraffic;
@@ -141,8 +142,7 @@ pub(crate) async fn list_peers(
let traffic = state.traffic.peer(&public_key).unwrap_or_default();
let sync_throughput = state
.throughput
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .lock_or_recover()
.get(&public_key)
.map(|estimate| ThroughputInfo {
bytes_per_sec: estimate.bytes_per_sec.round(),
diff --git a/src/api/stats/prometheus.rs b/src/api/stats/prometheus.rs
index 74c18e9..07a6cc8 100644
--- a/src/api/stats/prometheus.rs
+++ b/src/api/stats/prometheus.rs
@@ -7,6 +7,7 @@ use std::fmt::Write;
use tokio::time::Instant;
use super::StatsResponse;
+use crate::locks::MutexExt;
use crate::state::{AppState, Incidents, Liveness};
use crate::transport::traffic::{ByKind, Counter, PeerTraffic};
@@ -136,8 +137,7 @@ async fn peers(state: &AppState) -> Vec<Peer> {
.map(|rtt| rtt.as_secs_f64());
let throughput = state
.throughput
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .lock_or_recover()
.get(&key)
.map(|estimate| estimate.bytes_per_sec);
let traffic = state.traffic.peer(&key).unwrap_or_default();