summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-07 17:32:38 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-07 17:32:38 +0800
commitc663980c420bd8f1c95e5682325a908752030378 (patch)
tree7d487ea535b6b2076e46b3efc6ea681d8e929b2d
parentd87136744dc022b12a61539f6dd724eb19707d18 (diff)
downloadpttbbs-c663980c420bd8f1c95e5682325a908752030378.tar
pttbbs-c663980c420bd8f1c95e5682325a908752030378.tar.gz
pttbbs-c663980c420bd8f1c95e5682325a908752030378.tar.bz2
pttbbs-c663980c420bd8f1c95e5682325a908752030378.tar.lz
pttbbs-c663980c420bd8f1c95e5682325a908752030378.tar.xz
pttbbs-c663980c420bd8f1c95e5682325a908752030378.tar.zst
pttbbs-c663980c420bd8f1c95e5682325a908752030378.zip
favbuf, zapbuf swapout
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@462 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/board.c33
-rw-r--r--mbbsd/cache.c8
2 files changed, 39 insertions, 2 deletions
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 7001f730..b8ef6c08 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.48 2002/08/06 09:03:02 in2 Exp $ */
+/* $Id: board.c,v 1.49 2002/08/07 09:32:38 in2 Exp $ */
#include "bbs.h"
#define BRC_STRLEN 15 /* Length of board name */
#define BRC_MAXSIZE 24576
@@ -226,6 +226,10 @@ static boardstat_t *nbrd = NULL;
#define STR_BBSRC ".bbsrc"
#define STR_FAV ".fav"
+#ifdef OUTTA_CACHE
+int zaplength, favlength;
+#endif
+
void
init_brdbuf()
{
@@ -259,6 +263,11 @@ init_brdbuf()
favbuf[n] &= ~BRD_TAG;
brc_expire_time = login_start_time - 365 * 86400;
+
+#ifdef OUTTA_CACHE
+ outta_swapout((void **)&favbuf, (favlength = size + 4), 'f');
+ outta_swapout((void **)&zapbuf, (zaplength = size), 'z');
+#endif
}
void
@@ -267,6 +276,10 @@ save_brdbuf()
int fd, size;
char fname[60];
+#ifdef OUTTA_CACHE
+ outta_swapin((void **)&favbuf, favlength, 'f');
+ outta_swapin((void **)&zapbuf, zaplength, 'z');
+#endif
if (!zapbuf)
return;
setuserfile(fname, STR_BBSRC);
@@ -709,6 +722,14 @@ choose_board(int newflag)
char genbuf[200];
#endif
+#ifdef OUTTA_CACHE
+ static char depth = 0;
+ ++depth;
+ if( favbuf == NULL )
+ outta_swapin((void **)&favbuf, favlength, 'f');
+ if( zapbuf == NULL )
+ outta_swapin((void **)&zapbuf, zaplength, 'z');
+#endif
setutmpmode(newflag ? READNEW : READBRD);
brdnum = 0;
if (!cuser.userlevel) /* guest yank all boards */
@@ -1018,10 +1039,14 @@ choose_board(int newflag)
if (!(ptr->myattr & BRD_ZAP))
zapbuf[ptr->bid - 1] = now;
#ifdef OUTTA_CACHE
+ outta_swapout((void **)&favbuf, favlength, 'f');
+ outta_swapout((void **)&zapbuf, zaplength, 'z');
outta_swapout((void **)&nbrd, nbrdlength, 'b');
#endif
Read();
#ifdef OUTTA_CACHE
+ outta_swapin((void **)&favbuf, favlength, 'f');
+ outta_swapin((void **)&zapbuf, zaplength, 'z');
outta_swapin((void **)&nbrd, nbrdlength, 'b');
ptr = &nbrd[num];
#endif
@@ -1071,6 +1096,12 @@ choose_board(int newflag)
}
} while (ch != 'q');
free(nbrd);
+#ifdef OUTTA_CACHE
+ if( --depth == 0 ){
+ outta_swapout((void **)&favbuf, favlength, 'f');
+ outta_swapout((void **)&zapbuf, zaplength, 'z');
+ }
+#endif
}
int
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 630390c1..27202de7 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -1,4 +1,4 @@
-/* $Id: cache.c,v 1.46 2002/08/06 08:58:25 in2 Exp $ */
+/* $Id: cache.c,v 1.47 2002/08/07 09:32:38 in2 Exp $ */
#include "bbs.h"
#ifndef __FreeBSD__
@@ -1135,6 +1135,9 @@ void outta_swapout(void **ptr, int length, char cacheid)
{
char fn[64];
int fd;
+#ifdef DEBUG
+ vmsg("swap out (%c) %d bytes", cacheid, length);
+#endif
sprintf(fn, "cache/" MYHOSTNAME "%c%d", cacheid, currpid);
if( (fd = open(fn, O_WRONLY | O_CREAT, 0600)) < 0 )
abort_bbs(0);
@@ -1148,6 +1151,9 @@ void outta_swapin(void **ptr, int length, char cacheid)
{
char fn[64];
int fd;
+#ifdef DEBUG
+ vmsg("swap in (%c) %d bytes", cacheid, length);
+#endif
sprintf(fn, "cache/" MYHOSTNAME "%c%d", cacheid, currpid);
if( (fd = open(fn, O_RDONLY)) < 0 )
abort_bbs(0);