Merge pull request #22 from KolbeinNL/fix-lost-connection

Fix: dead connections used for commands (IMAP)
This commit is contained in:
rustmailer
2026-03-31 22:32:39 +08:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -25,7 +25,10 @@ impl bb8::ManageConnection for ImapConnectionManager {
}
// call this function before using the connection
async fn is_valid(&self, conn: &mut Self::Connection) -> RustMailerResult<()> {
match tokio::time::timeout(Duration::from_secs(5), conn.noop()).await {
if conn.is_bad {
return Err(raise_error!(format!("Connection marked broken"), ErrorCode::ImapCommandFailed));
}
match tokio::time::timeout(Duration::from_secs(5), conn.run_command_and_check_ok("NOOP")).await {
Ok(Ok(_)) => Ok(()),
Ok(Err(e)) => {
error!("IMAP connection validation failed: {:?}", e);
+1 -1
View File
@@ -16,7 +16,7 @@ use tokio_io_timeout::TimeoutStream;
use tokio_socks::tcp::Socks5Stream;
use tracing::error;
pub(crate) const TIMEOUT: Duration = Duration::from_secs(60);
pub(crate) const TIMEOUT: Duration = Duration::from_secs(3600);
pub(crate) async fn establish_tcp_connection_with_timeout(
address: SocketAddr,