aboutsummaryrefslogtreecommitdiffstats
path: root/libemail-engine
diff options
context:
space:
mode:
Diffstat (limited to 'libemail-engine')
-rw-r--r--libemail-engine/mail-ops.c16
1 files changed, 16 insertions, 0 deletions
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);