]> code.citadel.org Git - citadel.git/commitdiff
* CtdlOutputMsg() caches the most recently fetched message in memory. This
authorArt Cancro <ajc@citadel.org>
Sat, 13 Jul 2002 03:24:33 +0000 (03:24 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 13 Jul 2002 03:24:33 +0000 (03:24 +0000)
  eliminates the need to do multiple database fetches when we go back for
  additional MIME parts, etc.

citadel/ChangeLog
citadel/citserver.c
citadel/msgbase.c
citadel/server.h

index f7fa205bf43744272044ec35992f7e2ac4f70f17..279cc2e905e0fe1f974bffcd64aa3db1867cf6f0 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 591.64  2002/07/13 03:24:32  ajc
+ * CtdlOutputMsg() caches the most recently fetched message in memory.  This
+   eliminates the need to do multiple database fetches when we go back for
+   additional MIME parts, etc.
+
  Revision 591.63  2002/07/11 03:40:51  ajc
  * When outputting a multipart MIME message, supply the client with "pref="
    and "suff=" lines in addition to the "part=" lines.
@@ -3800,4 +3805,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 53f8066cc6788e25e17cdc840ce653dd517543aa..e68a21d1284e6238c90d29b3ce84ec68812032a4 100644 (file)
@@ -208,8 +208,12 @@ void RemoveContext (struct CitContext *con)
        unlink(con->temp);
        lprintf(3, "[%3d] Session ended.\n", con->cs_pid);
        
-
        syslog(LOG_NOTICE,"session %d: ended", con->cs_pid);
+
+       /* If we have a message in cache, free it */
+       if (CC->cached_msg != NULL) {
+               phree(CC->cached_msg);
+       }
        
        /* Deallocate any user-data attached to this session */
        deallocate_user_data(con);
index 68449500e7414922220b761a6877f3c7c2fd4662..c3c213591a497b2b8270cac61b6e79e6c9205cc7 100644 (file)
@@ -989,9 +989,22 @@ int CtdlOutputMsg(long msg_num,            /* message number (local) to fetch */
         */
 
        /*
-        * Fetch the message from disk
+        * Fetch the message from disk.  We also keep the most recently
+        * read message in memory, in case we want to read it again, or fetch
+        * MIME parts out of it, or whatever.
         */
-       TheMessage = CtdlFetchMessage(msg_num);
+       if ( (CC->cached_msg != NULL) && (CC->cached_msgnum == msg_num) ) {
+               TheMessage = CC->cached_msg;
+       }
+       else {
+               TheMessage = CtdlFetchMessage(msg_num);
+               if (CC->cached_msg != NULL) {
+                       phree(CC->cached_msg);
+               }
+               CC->cached_msg = TheMessage;
+               CC->cached_msgnum = msg_num;
+       }
+
        if (TheMessage == NULL) {
                if (do_proto) cprintf("%d Can't locate msg %ld on disk\n",
                        ERROR, msg_num);
@@ -1002,7 +1015,9 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
                        TheMessage, msg_num, mode,
                        headers_only, do_proto, crlf);
 
-       CtdlFreeMessage(TheMessage);
+       /* don't free the memory; we're keeping it in the cache */
+       /* CtdlFreeMessage(TheMessage); */
+
        return(retcode);
 }
 
index 127be4c9572fdfeb016ee487c81ed088c0a9b60d..0ac21564764806b3f5e93a3d71139759c529620a 100644 (file)
@@ -145,6 +145,9 @@ struct CitContext {
        char fake_hostname[64];                 /* Fake hostname <bc> */
        char fake_roomname[ROOMNAMELEN];        /* Fake roomname <bc> */
 
+       struct CtdlMessage *cached_msg;
+       long cached_msgnum;
+
        /* Dynamically allocated session data */
        struct CtdlSessData *FirstSessData;
 };