mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
fix(main): Prevent re-entrant read lock deadlock during reload
Reuse the already-held main_lock when checking module staleness in run() instead of re-acquiring server.mods.read().
This commit is contained in:
1 file changed
+5
-2
+5
-2
@@ -69,7 +69,7 @@ pub(crate) async fn run(server: &Arc<Server>, starts: bool) -> Result<(bool, boo
|
||||
|
||||
let reloads = server.server.reloading.swap(false, Ordering::AcqRel);
|
||||
|
||||
let stops = !reloads || stale(server).await? <= restart_thresh();
|
||||
let stops = !reloads || stale_from_mods(&main_lock)? <= restart_thresh();
|
||||
let starts = reloads && stops;
|
||||
if stops {
|
||||
let stop = main_mod.get::<StopFuncProto>("stop")?;
|
||||
@@ -140,7 +140,10 @@ async fn stale_count(server: &Arc<Server>) -> usize {
|
||||
|
||||
async fn stale(server: &Arc<Server>) -> Result<usize, Error> {
|
||||
let mods_lock = server.mods.read().await;
|
||||
let mods: &Vec<mods::Module> = &mods_lock;
|
||||
stale_from_mods(&mods_lock)
|
||||
}
|
||||
|
||||
fn stale_from_mods(mods: &[mods::Module]) -> Result<usize, Error> {
|
||||
for (i, module) in mods.iter().enumerate() {
|
||||
if module.deleted()? {
|
||||
return Ok(i);
|
||||
|
||||
Reference in new issue
Block a user