[Fix] Timeout bug causing infinite hang (#350)
This commit is contained in:
committed by
Alexis Mousset
parent
8336528f09
commit
6eff9d3bee
@@ -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>();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user