]> code.citadel.org Git - citadel.git/commitdiff
* msgbase.c: when committing a new message to the store, save its RFC822
authorArt Cancro <ajc@citadel.org>
Thu, 21 Apr 2005 17:28:51 +0000 (17:28 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 21 Apr 2005 17:28:51 +0000 (17:28 +0000)
  length to the metadata record immediately.  This will eliminate the need
  to calculate it later during a fetch operation.

citadel/ChangeLog
citadel/msgbase.c

index 8720d94659de4f7a5762957ae4e18e269e02ba72..883bed0d8056038b1ec0038c04b1bf25989805d9 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 645.6  2005/04/21 17:28:51  ajc
+ * msgbase.c: when committing a new message to the store, save its RFC822
+   length to the metadata record immediately.  This will eliminate the need
+   to calculate it later during a fetch operation.
+
  Revision 645.5  2005/04/14 15:53:55  ajc
  * Variable names, comments, documentation, etc...  removed the acronym 'BBS'
    in places where functionality is not specific to the use of Citadel as
@@ -6601,4 +6606,3 @@ 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 5c1dcd12931c85ffa1bcd0fcf0289cc4364e7ed4..3de8d06348bf2071b3cedae9f7d7bd3ffecbb282 100644 (file)
@@ -2042,6 +2042,27 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
        newmsgid = send_message(msg);
        if (newmsgid <= 0L) return(-5);
 
+       /* Measure how big this message will be when displayed as RFC822.
+        * Both POP and IMAP use this, and it's best to just take the hit now
+        * instead of having to potentially measure thousands of messages when
+        * a mailbox is opened later.
+        */
+
+       if (CC->redirect_buffer != NULL) {
+               lprintf(CTDL_ALERT, "CC->redirect_buffer is not NULL during message submission!\n");
+               abort();
+       }
+       CC->redirect_buffer = malloc(SIZ);
+       CC->redirect_len = 0;
+       CC->redirect_alloc = SIZ;
+       CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
+       smi.meta_rfc822_length = CC->redirect_len;
+       free(CC->redirect_buffer);
+       CC->redirect_buffer = NULL;
+       CC->redirect_len = 0;
+       CC->redirect_alloc = 0;
+       lprintf(CTDL_DEBUG, "Storing meta rfc822 length of %ld\n", smi.meta_rfc822_length);
+
        /* Write a supplemental message info record.  This doesn't have to
         * be a critical section because nobody else knows about this message
         * yet.