mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 18:36:30 +03:00
refactor: Make ConnectivityStore use a non-async lock (#7129)
Follow-up to https://github.com/chatmail/core/pull/7125: We now have a mix of non-async (parking_lot) and async (tokio) Mutexes used for the connectivity. We can just use non-async Mutexes, because we don't attempt to hold them over an await point. I also tested that we get a compiler error if we do try to hold one over an await point (rather than just deadlocking/blocking the executor on runtime). Not 100% sure about using the parking_lot rather than std Mutex, because since https://github.com/rust-lang/rust/issues/93740, parking_lot doesn't have a lot of advantages anymore. But as long as iroh depends on it, we might as well use it ourselves.
This commit is contained in:
@@ -227,7 +227,7 @@ impl SchedulerState {
|
||||
_ => return,
|
||||
};
|
||||
drop(inner);
|
||||
connectivity::idle_interrupted(inbox, oboxes).await;
|
||||
connectivity::idle_interrupted(inbox, oboxes);
|
||||
}
|
||||
|
||||
/// Indicate that the network likely is lost.
|
||||
@@ -244,7 +244,7 @@ impl SchedulerState {
|
||||
_ => return,
|
||||
};
|
||||
drop(inner);
|
||||
connectivity::maybe_network_lost(context, stores).await;
|
||||
connectivity::maybe_network_lost(context, stores);
|
||||
}
|
||||
|
||||
pub(crate) async fn interrupt_inbox(&self) {
|
||||
@@ -569,7 +569,7 @@ async fn fetch_idle(
|
||||
// The folder is not configured.
|
||||
// For example, this happens if the server does not have Sent folder
|
||||
// but watching Sent folder is enabled.
|
||||
connection.connectivity.set_not_configured(ctx).await;
|
||||
connection.connectivity.set_not_configured(ctx);
|
||||
connection.idle_interrupt_receiver.recv().await.ok();
|
||||
bail!("Cannot fetch folder {folder_meaning} because it is not configured");
|
||||
};
|
||||
@@ -659,7 +659,7 @@ async fn fetch_idle(
|
||||
.log_err(ctx)
|
||||
.ok();
|
||||
|
||||
connection.connectivity.set_idle(ctx).await;
|
||||
connection.connectivity.set_idle(ctx);
|
||||
|
||||
ctx.emit_event(EventType::ImapInboxIdle);
|
||||
|
||||
@@ -810,8 +810,8 @@ async fn smtp_loop(
|
||||
// Fake Idle
|
||||
info!(ctx, "SMTP fake idle started.");
|
||||
match &connection.last_send_error {
|
||||
None => connection.connectivity.set_idle(&ctx).await,
|
||||
Some(err) => connection.connectivity.set_err(&ctx, err).await,
|
||||
None => connection.connectivity.set_idle(&ctx),
|
||||
Some(err) => connection.connectivity.set_err(&ctx, err),
|
||||
}
|
||||
|
||||
// If send_smtp_messages() failed, we set a timeout for the fake-idle so that
|
||||
|
||||
Reference in New Issue
Block a user