[evolution-data-server] Fix failure to RSET SMTP connection before re-use.



commit e3aaafd2b5b368d4659b3eb88d45e7fbc6e0389d
Author: David Woodhouse <David Woodhouse intel com>
Date:   Tue Oct 19 12:47:39 2010 +0100

    Fix failure to RSET SMTP connection before re-use.
    
    We were only issuing a RSET in the case that we *didn't* need to, when
    we'd sent a mail successfully. Fix that, so we send RSET after the RCPT
    or DATA commands *fail*.
    
    Do it by setting a 'need_rset' flag and then only actually sending RSET
    if the connection really is going to be re-used. Most of the time, the
    connection doesn't get re-used anyway so sending RSET would just be a
    waste of time.
    
    Mentioned in bug 630560.

 camel/providers/smtp/camel-smtp-transport.c |   15 ++++++++++++---
 camel/providers/smtp/camel-smtp-transport.h |    1 +
 2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 2b17ec0..f437d4c 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -619,6 +619,14 @@ smtp_send_to_sync (CamelTransport *transport,
 	/* find out if the message has 8bit mime parts */
 	has_8bit_parts = camel_mime_message_has_8bit_parts (message);
 
+	/* If the connection needs a ReSET, then do so */
+	if (smtp_transport->need_rset &&
+	    !smtp_rset (smtp_transport, cancellable, error)) {
+		camel_operation_pop_message (cancellable);
+		return FALSE;
+	}
+	smtp_transport->need_rset = FALSE;
+
 	/* rfc1652 (8BITMIME) requires that you notify the ESMTP daemon that
 	   you'll be sending an 8bit mime message at "MAIL FROM:" time. */
 	if (!smtp_mail (
@@ -633,6 +641,7 @@ smtp_send_to_sync (CamelTransport *transport,
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot send message: no recipients defined."));
 		camel_operation_pop_message (cancellable);
+		smtp_transport->need_rset = TRUE;
 		return FALSE;
 	}
 
@@ -646,6 +655,7 @@ smtp_send_to_sync (CamelTransport *transport,
 				_("Cannot send message: "
 				  "one or more invalid recipients"));
 			camel_operation_pop_message (cancellable);
+			smtp_transport->need_rset = TRUE;
 			return FALSE;
 		}
 
@@ -653,6 +663,7 @@ smtp_send_to_sync (CamelTransport *transport,
 		if (!smtp_rcpt (smtp_transport, enc, cancellable, error)) {
 			g_free (enc);
 			camel_operation_pop_message (cancellable);
+			smtp_transport->need_rset = TRUE;
 			return FALSE;
 		}
 		g_free (enc);
@@ -660,12 +671,10 @@ smtp_send_to_sync (CamelTransport *transport,
 
 	if (!smtp_data (smtp_transport, message, cancellable, error)) {
 		camel_operation_pop_message (cancellable);
+		smtp_transport->need_rset = TRUE;
 		return FALSE;
 	}
 
-	/* reset the service for our next transfer session */
-	smtp_rset (smtp_transport, cancellable, NULL);
-
 	camel_operation_pop_message (cancellable);
 
 	return TRUE;
diff --git a/camel/providers/smtp/camel-smtp-transport.h b/camel/providers/smtp/camel-smtp-transport.h
index faebdb2..20e0d2d 100644
--- a/camel/providers/smtp/camel-smtp-transport.h
+++ b/camel/providers/smtp/camel-smtp-transport.h
@@ -69,6 +69,7 @@ struct _CamelSmtpTransport {
 
 	guint32 flags;
 
+	gboolean need_rset;
 	gboolean connected;
 	struct sockaddr *localaddr;
 	socklen_t localaddrlen;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]