diff --git a/mm2src/mm2_core/src/mm_ctx.rs b/mm2src/mm2_core/src/mm_ctx.rs index 98864df40f..b3cf3da1e7 100644 --- a/mm2src/mm2_core/src/mm_ctx.rs +++ b/mm2src/mm2_core/src/mm_ctx.rs @@ -55,9 +55,9 @@ mod healthcheck_defaults { pub struct Healthcheck { /// Links the RPC context to the P2P context to handle health check responses. - pub response_handler: AsyncMutex>>, + pub response_handler: Mutex>>, /// This is used to record healthcheck sender peers in an expirable manner to prevent DDoS attacks. - pub ddos_shield: AsyncMutex>, + pub ddos_shield: Mutex>, pub config: HealthcheckConfig, } @@ -234,8 +234,8 @@ impl MmCtx { #[cfg(not(target_arch = "wasm32"))] async_sqlite_connection: Constructible::default(), healthcheck: Healthcheck { - response_handler: AsyncMutex::new(ExpirableMap::default()), - ddos_shield: AsyncMutex::new(ExpirableMap::default()), + response_handler: Mutex::new(ExpirableMap::default()), + ddos_shield: Mutex::new(ExpirableMap::default()), config: HealthcheckConfig::default(), }, } diff --git a/mm2src/mm2_main/src/lp_healthcheck.rs b/mm2src/mm2_main/src/lp_healthcheck.rs index b7eddb3d70..30884987a7 100644 --- a/mm2src/mm2_main/src/lp_healthcheck.rs +++ b/mm2src/mm2_main/src/lp_healthcheck.rs @@ -269,10 +269,11 @@ pub async fn peer_connection_healthcheck_rpc( let (tx, rx): (Sender<()>, Receiver<()>) = oneshot::channel(); - let mut book = ctx.healthcheck.response_handler.lock().await; - book.clear_expired_entries(); - book.insert(target_peer_id.to_string(), tx, *address_record_exp); - drop(book); + { + let mut book = ctx.healthcheck.response_handler.lock().unwrap(); + book.clear_expired_entries(); + book.insert(target_peer_id.to_string(), tx, *address_record_exp); + } broadcast_p2p_msg(&ctx, peer_healthcheck_topic(&target_peer_id), encoded_message, None); @@ -300,7 +301,7 @@ pub(crate) async fn process_p2p_healthcheck_message(ctx: &MmArc, message: mm2_li let sender_peer = data.sender_peer().to_owned(); - let mut ddos_shield = ctx.healthcheck.ddos_shield.lock().await; + let mut ddos_shield = ctx.healthcheck.ddos_shield.lock().unwrap(); ddos_shield.clear_expired_entries(); if ddos_shield .insert( @@ -345,7 +346,7 @@ pub(crate) async fn process_p2p_healthcheck_message(ctx: &MmArc, message: mm2_li broadcast_p2p_msg(&ctx_c, topic, encoded_msg, None); } else { // The requested peer is healthy; signal the response channel. - let mut response_handler = ctx_c.healthcheck.response_handler.lock().await; + let mut response_handler = ctx_c.healthcheck.response_handler.lock().unwrap(); if let Some(tx) = response_handler.remove(&sender_peer.to_string()) { if tx.send(()).is_err() { log::error!("Result channel isn't present for peer '{sender_peer}'.");