From 28391aa9253135c92228b7c6ebd49268e23acdee Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 8 Jul 2014 13:00:34 +0200 Subject: Disconnect the store when connected it on send from an Outbox When there was a send from the Outbox folder, then the transport service was connected when needed, but not disconnected after the send was finished. That could mean that any later send from the Outbox for this service could fail.because the server disconnected meanwhile. --- libemail-engine/mail-ops.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libemail-engine') diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c index 67fc5a9742..c12555ff5d 100644 --- a/libemail-engine/mail-ops.c +++ b/libemail-engine/mail-ops.c @@ -591,6 +591,7 @@ mail_send_message (struct _send_queue_msg *m, CamelMimeMessage *message; gint i; GError *local_error = NULL; + gboolean did_connect = FALSE; message = camel_folder_get_message_sync ( queue, uid, cancellable, error); @@ -668,6 +669,8 @@ mail_send_message (struct _send_queue_msg *m, if (!camel_service_connect_sync (service, cancellable, error)) goto exit; + + did_connect = TRUE; } /* expand, or remove empty, group addresses */ @@ -841,6 +844,19 @@ mail_send_message (struct _send_queue_msg *m, } exit: + if (did_connect) { + /* Disconnect regardless of error or cancellation, + * but be mindful of these conditions when calling + * camel_service_disconnect_sync(). */ + if (g_cancellable_is_cancelled (cancellable)) { + camel_service_disconnect_sync (service, FALSE, NULL, NULL); + } else if (error != NULL) { + camel_service_disconnect_sync (service, FALSE, cancellable, NULL); + } else { + camel_service_disconnect_sync (service, TRUE, cancellable, &local_error); + } + } + if (local_error != NULL) g_propagate_error (error, local_error); -- cgit v1.2.3