* CtdlOutputPreLoadedMessage() -- buffer up to 1K characters
authorArt Cancro <ajc@citadel.org>
Thu, 4 Jan 2007 20:18:26 +0000 (20:18 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 4 Jan 2007 20:18:26 +0000 (20:18 +0000)
   when outputting raw RFC822 instead of outputting one character at a time.
  This will reduce system call overhead and also improve SSL performance.

citadel/msgbase.c
citadel/serv_imap.c

index 03260b31f1603c22535d33d81a5664b3242d1675..099af20dcd920054873b3340abe9ecbc40864355 100644 (file)
@@ -1745,30 +1745,40 @@ START_TEXT:
                        ++start_of_text;
                        start_of_text = strstr(start_of_text, "\n");
                        ++start_of_text;
+
+                       char outbuf[1024];
+                       int outlen = 0;
+                       int nllen = strlen(nl);
                        while (ch=*mptr, ch!=0) {
                                if (ch==13) {
                                        /* do nothing */
                                }
-                               else switch(headers_only) {
-                                       case HEADERS_NONE:
-                                               if (mptr >= start_of_text) {
-                                                       if (ch == 10) cprintf("%s", nl);
-                                                       else cprintf("%c", ch);
+                               else {
+                                       if (
+                                               ((headers_only == HEADERS_NONE) && (mptr >= start_of_text))
+                                          ||   ((headers_only == HEADERS_ONLY) && (mptr < start_of_text))
+                                          ||   ((headers_only != HEADERS_NONE) && (headers_only != HEADERS_ONLY))
+                                       ) {
+                                               if (ch == 10) {
+                                                       sprintf(&outbuf[outlen], "%s", nl);
+                                                       outlen += nllen;
                                                }
-                                               break;
-                                       case HEADERS_ONLY:
-                                               if (mptr < start_of_text) {
-                                                       if (ch == 10) cprintf("%s", nl);
-                                                       else cprintf("%c", ch);
+                                               else {
+                                                       outbuf[outlen++] = ch;
                                                }
-                                               break;
-                                       default:
-                                               if (ch == 10) cprintf("%s", nl);
-                                               else cprintf("%c", ch);
-                                               break;
+                                       }
                                }
                                ++mptr;
+                               if (outlen > 1000) {
+                                       client_write(outbuf, outlen);
+                                       outlen = 0;
+                               }
+                       }
+                       if (outlen > 0) {
+                               client_write(outbuf, outlen);
+                               outlen = 0;
                        }
+
                        goto DONE;
                }
        }
index c241a640798db25c75450fa9305df71f60a72af3..9a52c1f0122bbd292fd6f0de69d0289442443b43 100644 (file)
@@ -1619,9 +1619,7 @@ void imap_command_loop(void)
 
        gettimeofday(&tv2, NULL);
        total_time = (tv2.tv_usec + (tv2.tv_sec * 1000000)) - (tv1.tv_usec + (tv1.tv_sec * 1000000));
-       lprintf(CTDL_DEBUG, "IMAP %s %s took %ld.%ld seconds\n",
-               parms[1],
-               (!strcasecmp(parms[1], "uid") ? parms[2] : ""),
+       lprintf(CTDL_DEBUG, "IMAP command completed in %ld.%ld seconds\n",
                (total_time / 1000000),
                (total_time % 1000000)
        );