$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
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);
*/
/*
- * 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);
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);
}
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;
};