From bb332fc6a0c1ad636ebc7aeaa0db42deabe19407 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 20 May 2004 19:16:53 +0000 Subject: Fixes bug #42295 and the infinite loop part of bug #58766 (these 2 bugs 2004-05-20 Jeffrey Stedfast Fixes bug #42295 and the infinite loop part of bug #58766 (these 2 bugs are almost identical, except the server responses are broken in different ways). * providers/imap/camel-imap-folder.c (imap_update_summary): Remove the kludge to re-SELECT the folder to force a re-FETCH of message-info's. This 1) doesn't do what it was meant to do and 2) has a tendency to cause infinite loops with broken servers such as Courier-IMAP. (imap_update_summary): Rework the loop that adds messages to the summary such that if we encounetr an error, we break out and set an exception (we can keep the messages up to the point of failure, but none after that because otherwise our uid-to-seqid mapping would be inconsistant with that of the server and could potentially cause data loss). svn path=/trunk/; revision=26019 --- camel/ChangeLog | 18 +++++++++++++ camel/providers/imap/camel-imap-folder.c | 45 ++++++++++++++++---------------- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 2b55f9689e..ddd90a7ddc 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,21 @@ +2004-05-20 Jeffrey Stedfast + + Fixes bug #42295 and the infinite loop part of bug #58766 (these 2 + bugs are almost identical, except the server responses are broken + in different ways). + + * providers/imap/camel-imap-folder.c (imap_update_summary): Remove + the kludge to re-SELECT the folder to force a re-FETCH of + message-info's. This 1) doesn't do what it was meant to do and 2) + has a tendency to cause infinite loops with broken servers such as + Courier-IMAP. + (imap_update_summary): Rework the loop that adds messages to the + summary such that if we encounetr an error, we break out and set + an exception (we can keep the messages up to the point of failure, + but none after that because otherwise our uid-to-seqid mapping + would be inconsistant with that of the server and could + potentially cause data loss). + 2004-05-20 Not Zed * providers/nntp/camel-nntp-folder.c (nntp_folder_get_message): diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index b75373a375..d2da841599 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -2459,19 +2459,33 @@ imap_update_summary (CamelFolder *folder, int exists, mi = messages->pdata[i]; if (!mi) { g_warning ("No information for message %d", i + first); - continue; + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Incomplete server response: no information provided for message %d"), + i + first); + break; } uid = (char *)camel_message_info_uid(mi); if (uid[0] == 0) { g_warning("Server provided no uid: message %d", i + first); - continue; + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Incomplete server response: no UID provided for message %d"), + i + first); + break; } info = camel_folder_summary_uid(folder->summary, uid); if (info) { + for (seq = 0; seq < camel_folder_summary_count (folder->summary); seq++) { + if (folder->summary->messages->pdata[seq] == info) + break; + } + g_warning("Message already present? %s", camel_message_info_uid(mi)); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Unexpected server response: Identical UIDs provided for messages %d and %d"), + seq + 1, i + first); + camel_folder_summary_info_free(folder->summary, info); - camel_folder_summary_info_free(folder->summary, mi); - continue; + break; } camel_folder_summary_add (folder->summary, mi); @@ -2480,27 +2494,14 @@ imap_update_summary (CamelFolder *folder, int exists, if ((mi->flags & CAMEL_IMAP_MESSAGE_RECENT)) camel_folder_change_info_recent_uid(changes, camel_message_info_uid (mi)); } - g_ptr_array_free (messages, TRUE); - /* Kludge around Microsoft Exchange 5.5 IMAP - See bug #5348 for details */ - if (camel_folder_summary_count (folder->summary) != exists) { - CamelImapStore *imap_store = (CamelImapStore *) folder->parent_store; - CamelImapResponse *response; - - /* forget the currently selected folder */ - if (imap_store->current_folder) { - camel_object_unref (CAMEL_OBJECT (imap_store->current_folder)); - imap_store->current_folder = NULL; - } - - /* now re-select it and process the EXISTS response */ - response = camel_imap_command (imap_store, folder, ex, NULL); - if (response) { - camel_imap_folder_selected (folder, response, NULL); - camel_imap_response_free (imap_store, response); - } + for ( ; i < messages->len; i++) { + if ((mi = messages->pdata[i])) + camel_folder_summary_info_free(folder->summary, mi); } + g_ptr_array_free (messages, TRUE); + return; lose: -- cgit v1.2.3