]> code.citadel.org Git - citadel.git/commitdiff
* More IMAP optimizations, including the application of our latest "don't
authorArt Cancro <ajc@citadel.org>
Mon, 2 May 2005 20:52:42 +0000 (20:52 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 2 May 2005 20:52:42 +0000 (20:52 +0000)
  fetch the message body" trick to ENVELOPE and INTERNALDATE fetches, to
  make MS-Outbreak spread email viruses faster.

citadel/ChangeLog
citadel/imap_fetch.c
citadel/serv_imap.c

index 4ea879ef788b35482c67112e1ce73fd673cd4525..df8376e4da4825f48f94700519036d021d05677e 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 645.18  2005/05/02 20:52:42  ajc
+ * More IMAP optimizations, including the application of our latest "don't
+   fetch the message body" trick to ENVELOPE and INTERNALDATE fetches, to
+   make MS-Outbreak spread email viruses faster.
+
  Revision 645.17  2005/05/02 16:09:52  ajc
  * serv_imap.c: implemented the RFC 3501 suggestion that the initial
    greeting, and the response to the LOGIN command, include an output
@@ -6656,3 +6661,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 c33a9c1d17ed039178b00270307075648be3a88b..9c54c6499b1f04454c7774c919b349a47c57f3e9 100644 (file)
@@ -394,7 +394,7 @@ void imap_output_envelope_addr(char *addr) {
  * Note that the imap_strout() function can cleverly output NULL fields as NIL,
  * so we don't have to check for that condition like we do elsewhere.
  */
-void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
+void imap_fetch_envelope(struct CtdlMessage *msg) {
        char datestringbuf[SIZ];
        time_t msgdate;
        char *fieldptr = NULL;
@@ -901,6 +901,7 @@ void imap_fetch_bodystructure (long msgnum, char *item,
 void imap_do_fetch_msg(int seq, int num_items, char **itemlist) {
        int i;
        struct CtdlMessage *msg = NULL;
+       int body_loaded = 0;
 
        cprintf("* %d FETCH (", seq);
 
@@ -941,16 +942,29 @@ void imap_do_fetch_msg(int seq, int num_items, char **itemlist) {
                /* Otherwise, load the message into memory.
                 */
                else if (!strcasecmp(itemlist[i], "BODYSTRUCTURE")) {
-                       if (msg == NULL) msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
+                       if ((msg != NULL) && (!body_loaded)) {
+                               CtdlFreeMessage(msg);   /* need the whole thing */
+                               msg = NULL;
+                       }
+                       if (msg == NULL) {
+                               msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
+                               body_loaded = 1;
+                       }
                        imap_fetch_bodystructure(IMAP->msgids[seq-1],
                                        itemlist[i], msg);
                }
                else if (!strcasecmp(itemlist[i], "ENVELOPE")) {
-                       if (msg == NULL) msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
-                       imap_fetch_envelope(IMAP->msgids[seq-1], msg);
+                       if (msg == NULL) {
+                               msg = CtdlFetchMessage(IMAP->msgids[seq-1], 0);
+                               body_loaded = 0;
+                       }
+                       imap_fetch_envelope(msg);
                }
                else if (!strcasecmp(itemlist[i], "INTERNALDATE")) {
-                       if (msg == NULL) msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
+                       if (msg == NULL) {
+                               msg = CtdlFetchMessage(IMAP->msgids[seq-1], 0);
+                               body_loaded = 0;
+                       }
                        imap_fetch_internaldate(msg);
                }
 
@@ -1192,7 +1206,7 @@ void imap_pick_range(char *supplied_range, int is_uid) {
  */
 void imap_fetch(int num_parms, char *parms[]) {
        char items[SIZ];
-       char *itemlist[SIZ];
+       char *itemlist[512];
        int num_items;
        int i;
 
@@ -1224,7 +1238,7 @@ void imap_fetch(int num_parms, char *parms[]) {
  */
 void imap_uidfetch(int num_parms, char *parms[]) {
        char items[SIZ];
-       char *itemlist[SIZ];
+       char *itemlist[512];
        int num_items;
        int i;
        int have_uid_item = 0;
@@ -1249,12 +1263,16 @@ void imap_uidfetch(int num_parms, char *parms[]) {
        }
 
        /* If the "UID" item was not included, we include it implicitly
-        * because this is a UID FETCH command
+        * (at the beginning) because this is a UID FETCH command
         */
        for (i=0; i<num_items; ++i) {
                if (!strcasecmp(itemlist[i], "UID")) ++have_uid_item;
        }
-       if (have_uid_item == 0) itemlist[num_items++] = "UID";
+       if (have_uid_item == 0) {
+               memmove(&itemlist[1], &itemlist[0], (sizeof(itemlist[0]) * num_items));
+               ++num_items;
+               itemlist[0] = "UID";
+       }
 
        imap_do_fetch(num_items, itemlist);
        cprintf("%s OK UID FETCH completed\r\n", parms[0]);
index 7b9ce5074efa61ce07ef921fda1b842621292f69..2893bbff9e8628572652ee0cb584481b0ad91006 100644 (file)
@@ -637,7 +637,7 @@ void imap_select(int num_parms, char *parms[])
        cprintf("* %d EXISTS\r\n", msgs);
        cprintf("* %d RECENT\r\n", new);
 
-       cprintf("* OK [UIDVALIDITY 0] UID validity status\r\n");
+       cprintf("* OK [UIDVALIDITY 1] UID validity status\r\n");
        cprintf("* OK [UIDNEXT %ld] Predicted next UID\r\n", CitControl.MMhighest + 1);
 
        /* Note that \Deleted is a valid flag, but not a permanent flag,