mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 22:06:29 +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:
@@ -325,7 +325,7 @@ impl Imap {
|
||||
}
|
||||
|
||||
info!(context, "Connecting to IMAP server.");
|
||||
self.connectivity.set_connecting(context).await;
|
||||
self.connectivity.set_connecting(context);
|
||||
|
||||
self.conn_last_try = tools::Time::now();
|
||||
const BACKOFF_MIN_MS: u64 = 2000;
|
||||
@@ -408,7 +408,7 @@ impl Imap {
|
||||
"IMAP-LOGIN as {}",
|
||||
lp.user
|
||||
)));
|
||||
self.connectivity.set_preparing(context).await;
|
||||
self.connectivity.set_preparing(context);
|
||||
info!(context, "Successfully logged into IMAP server.");
|
||||
return Ok(session);
|
||||
}
|
||||
@@ -466,7 +466,7 @@ impl Imap {
|
||||
let mut session = match self.connect(context, configuring).await {
|
||||
Ok(session) => session,
|
||||
Err(err) => {
|
||||
self.connectivity.set_err(context, &err).await;
|
||||
self.connectivity.set_err(context, &err);
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
@@ -692,7 +692,7 @@ impl Imap {
|
||||
}
|
||||
|
||||
if !uids_fetch.is_empty() {
|
||||
self.connectivity.set_working(context).await;
|
||||
self.connectivity.set_working(context);
|
||||
}
|
||||
|
||||
let (sender, receiver) = async_channel::unbounded();
|
||||
|
||||
Reference in New Issue
Block a user