Skip to content

Commit 42e5e03

Browse files
Alexander Krotovlink2xt
authored andcommitted
command_with_timeout: apply timeouts separately to read and write
Timeout should be restarted after successful write operation.
1 parent a251e38 commit 42e5e03

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/smtp/client/inner.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,8 @@ impl<S: Connector + Write + Read + Unpin> InnerClient<S> {
207207
command: C,
208208
timeout: Option<&Duration>,
209209
) -> SmtpResult {
210-
with_timeout(timeout, async {
211-
self.as_mut().write(command.to_string().as_bytes()).await?;
212-
let res = self.read_response_no_timeout().await?;
213-
214-
Ok(res)
215-
})
216-
.await
210+
with_timeout(timeout, self.as_mut().write(command.to_string().as_bytes())).await?;
211+
with_timeout(timeout, self.read_response_no_timeout()).await
217212
}
218213

219214
/// Writes the given data to the server.

0 commit comments

Comments
 (0)