mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
better naming, less code
This commit is contained in:
15
src/job.rs
15
src/job.rs
@@ -205,17 +205,12 @@ impl Job {
|
|||||||
Status::RetryLater
|
Status::RetryLater
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// if the connection was successfully used more than 60
|
if smtp.has_maybe_stale_connection() {
|
||||||
// seconds ago, try an immediate reconnect.
|
info!(context, "stale connection? immediately reconnecting");
|
||||||
let mut res2 = Status::RetryLater;
|
Status::RetryNow
|
||||||
if let Some(secs) = smtp.secs_since_last_success() {
|
} else {
|
||||||
if secs > 60 {
|
Status::RetryLater
|
||||||
info!(context, "stale connection? triggering reconnect");
|
|
||||||
res2 = Status::RetryNow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res2
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,13 +77,13 @@ impl Smtp {
|
|||||||
self.last_success = None;
|
self.last_success = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return number of seconds since last success or None if
|
/// Return true if smtp was connected but is not known to
|
||||||
/// no success-time is recorded in this session.
|
/// have been successfully used the last 60 seconds
|
||||||
pub fn secs_since_last_success(&self) -> Option<u64> {
|
pub fn has_maybe_stale_connection(&self) -> bool {
|
||||||
if let Some(last_success) = self.last_success {
|
if let Some(last_success) = self.last_success {
|
||||||
Some(Instant::now().duration_since(last_success).as_secs())
|
Instant::now().duration_since(last_success).as_secs() > 60
|
||||||
} else {
|
} else {
|
||||||
None
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user