Use sync RwLock for debug_logging

This avoids the need for potentially expensive block_in_place(),
but is unlikely to actually block the thread as holding write lock is rare.
This commit is contained in:
link2xt
2023-04-16 18:48:06 +00:00
parent 2b7ee85e30
commit 4716fcef94
5 changed files with 17 additions and 9 deletions

View File

@@ -134,7 +134,7 @@ pub(crate) async fn set_debug_logging_xdc(ctx: &Context, id: Option<MsgId>) -> a
)
.await?;
{
let debug_logging = &mut *ctx.debug_logging.write().await;
let debug_logging = &mut *ctx.debug_logging.write().expect("RwLock is poisoned");
match debug_logging {
// Switch logging xdc
Some(debug_logging) => debug_logging.msg_id = msg_id,
@@ -162,7 +162,7 @@ pub(crate) async fn set_debug_logging_xdc(ctx: &Context, id: Option<MsgId>) -> a
ctx.sql
.set_raw_config(Config::DebugLogging.as_ref(), None)
.await?;
*ctx.debug_logging.write().await = None;
*ctx.debug_logging.write().expect("RwLock is poisoned") = None;
info!(ctx, "removing logging webxdc");
}
}