[Fix] Timeout bug causing infinite hang (#350)

This commit is contained in:
Daniel Hauser
2019-09-18 20:28:14 +02:00
committed by Alexis Mousset
parent 8336528f09
commit 6eff9d3bee
2 changed files with 4 additions and 4 deletions

View File

@@ -144,7 +144,7 @@ impl<S: Connector + Write + Read + Timeout + Debug> InnerClient<S> {
addr: &A,
timeout: Option<Duration>,
tls_parameters: Option<&ClientTlsParameters>,
) -> SmtpResult {
) -> Result<(), Error> {
// Connect should not be called when the client is already connected
if self.stream.is_some() {
return_err!("The connection is already established", self);
@@ -161,8 +161,7 @@ impl<S: Connector + Write + Read + Timeout + Debug> InnerClient<S> {
// Try to connect
self.set_stream(Connector::connect(&server_addr, timeout, tls_parameters)?);
self.read_response()
Ok(())
}
/// Checks if the server is connected using the NOOP SMTP command
@@ -246,7 +245,7 @@ impl<S: Connector + Write + Read + Timeout + Debug> InnerClient<S> {
}
/// Gets the SMTP response
fn read_response(&mut self) -> SmtpResult {
pub fn read_response(&mut self) -> SmtpResult {
let mut raw_response = String::new();
let mut response = raw_response.parse::<Response>();

View File

@@ -276,6 +276,7 @@ impl<'a> SmtpTransport {
)?;
self.client.set_timeout(self.client_info.timeout)?;
let _response = self.client.read_response()?;
// Log the connection
info!("connection established to {}", self.client_info.server_addr);