Skip to content

Commit

Permalink
up to 4 connections
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Aug 26, 2024
1 parent 77c726c commit ecb5dd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/imap/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,14 @@ impl Client {
connection_attempt_set.spawn(fut);
}

// Start second connection attempt 300 ms after the first.
delay_set.spawn(tokio::time::sleep(Duration::from_millis(300)));

// Start third connection attempt if we have not managed to connect in 10 seconds.
delay_set.spawn(tokio::time::sleep(Duration::from_secs(10)));
// Start second, third and fourth connection attempt 300 ms, 10 s and 15 s after the first.
for delay in [
Duration::from_millis(300),
Duration::from_secs(10),
Duration::from_secs(15),
] {
delay_set.spawn(tokio::time::sleep(delay));
}

let mut first_error = None;
loop {
Expand Down
13 changes: 8 additions & 5 deletions src/smtp/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,14 @@ async fn connect_stream(
connection_attempt_set.spawn(fut);
}

// Start second connection attempt 300 ms after the first.
delay_set.spawn(tokio::time::sleep(Duration::from_millis(300)));

// Start third connection attempt if we have not managed to connect in 10 seconds.
delay_set.spawn(tokio::time::sleep(Duration::from_secs(10)));
// Start second, third and fourth connection attempt 300 ms, 10 s and 15 s after the first.
for delay in [
Duration::from_millis(300),
Duration::from_secs(10),
Duration::from_secs(15),
] {
delay_set.spawn(tokio::time::sleep(delay));
}

let mut first_error = None;
loop {
Expand Down

0 comments on commit ecb5dd5

Please sign in to comment.