* imap_fetch.c: fixed a bug in the IMAP FETCH BODY code that was causing the
authorArt Cancro <ajc@citadel.org>
Mon, 29 Aug 2005 20:49:50 +0000 (20:49 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 29 Aug 2005 20:49:50 +0000 (20:49 +0000)
  "most recently fetched message" cache to be burned even when it shouldn't
  have been.  This was causing abominally slow message load time when a message
  contains attachments and the MUA is a client such as Thunderbird that does
  partial fetches.

citadel/ChangeLog
citadel/imap_fetch.c

index 391c9c3b2bf542348e4e701a6fb026283485a011..f979f8917b8c516a113b7d374e6957d297c4bc26 100644 (file)
@@ -1,4 +1,11 @@
 $Log$
+Revision 654.20  2005/08/29 20:49:50  ajc
+* imap_fetch.c: fixed a bug in the IMAP FETCH BODY code that was causing the
+  "most recently fetched message" cache to be burned even when it shouldn't
+  have been.  This was causing abominally slow message load time when a message
+  contains attachments and the MUA is a client such as Thunderbird that does
+  partial fetches.
+
 Revision 654.19  2005/08/23 04:00:01  ajc
 * Mailing list messages are now customized with a To: header for each
   recipient.  This uses more overhead but makes delivery more reliable.
@@ -7064,3 +7071,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 1ec73351f5600deeec41ef798db329c89e933570..88df3e17ad717e807a040a832481110c3fbb1316 100644 (file)
@@ -566,6 +566,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
        size_t pstart, pbytes;
        int loading_body_now = 0;
        int need_body = 1;
+       int burn_the_cache = 0;
 
        /* extract section */
        safestrncpy(section, item, sizeof section);
@@ -581,9 +582,17 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
         * same message again.
         */
        if (IMAP->cached_body != NULL) {
-               if ((IMAP->cached_bodymsgnum != msgnum)
-                  || ( (IMAP->cached_body_withbody) || (!need_body) )
-                  || (strcasecmp(IMAP->cached_bodypart, section)) ) {
+               if (IMAP->cached_bodymsgnum != msgnum) {
+                       burn_the_cache = 1;
+               }
+               else if ( (!IMAP->cached_body_withbody) && (need_body) ) {
+                       burn_the_cache = 1;
+               }
+               else if (strcasecmp(IMAP->cached_bodypart, section)) {
+                       burn_the_cache = 1;
+               }
+               if (burn_the_cache) {
+                       /* Yup, go ahead and burn the cache. */
                        free(IMAP->cached_body);
                        IMAP->cached_body_len = 0;
                        IMAP->cached_body = NULL;