fix: do not lock the account manager for the whole duration of background_fetch

This commit is contained in:
link2xt
2024-10-25 21:23:43 +00:00
parent 51a1762228
commit f396ff4297
3 changed files with 56 additions and 28 deletions

View File

@@ -4882,12 +4882,12 @@ pub unsafe extern "C" fn dc_accounts_background_fetch(
}
let accounts = &*accounts;
block_on(async move {
let accounts = accounts.read().await;
accounts
.background_fetch(Duration::from_secs(timeout_in_seconds))
.await;
});
let background_fetch_future = {
let lock = block_on(accounts.read());
lock.background_fetch(Duration::from_secs(timeout_in_seconds))
};
// At this point account manager is not locked anymore.
block_on(background_fetch_future);
1
}