From 674005bcc479ec52064b68f81ae27b720e1eb365 Mon Sep 17 00:00:00 2001 From: in2 Date: Tue, 6 Aug 2002 07:33:35 +0000 Subject: OUTTA_CACHE, nbrd git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@453 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/board.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/mbbsd/board.c b/mbbsd/board.c index 56d2469a..149aa33c 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1,4 +1,4 @@ -/* $Id: board.c,v 1.44 2002/07/27 10:06:19 kcwu Exp $ */ +/* $Id: board.c,v 1.45 2002/08/06 07:33:35 in2 Exp $ */ #include "bbs.h" #define BRC_STRLEN 15 /* Length of board name */ #define BRC_MAXSIZE 24576 @@ -220,6 +220,7 @@ typedef struct { } boardstat_t; static int *zapbuf = NULL, *favbuf; +static int nbrdlength; static boardstat_t *nbrd = NULL; #define STR_BBSRC ".bbsrc" @@ -445,7 +446,8 @@ load_boards(char *key) } brdnum = 0; if (class_bid <= 0) { - nbrd = (boardstat_t *) malloc(numboards * sizeof(boardstat_t)); + nbrdlength = numboards * sizeof(boardstat_t); + nbrd = (boardstat_t *) malloc(nbrdlength); for (i = 0; i < numboards; i++) { if ((bptr = SHM->bsorted[type][i]) == NULL) continue; @@ -463,7 +465,8 @@ load_boards(char *key) qsort(nbrd, brdnum, sizeof(boardstat_t), cmpboardfriends); } } else { - nbrd = (boardstat_t *) malloc(bptr->childcount * sizeof(boardstat_t)); + nbrdlength = bptr->childcount * sizeof(boardstat_t); + nbrd = (boardstat_t *) malloc(nbrdlength); for (bptr = bptr->firstchild[type]; bptr != (boardheader_t *) ~ 0; bptr = bptr->next[type]) { n = (int)(bptr - bcache); @@ -1014,7 +1017,27 @@ choose_board(int newflag) board_visit_time = zapbuf[ptr->bid - 1]; if (!(ptr->myattr & BRD_ZAP)) zapbuf[ptr->bid - 1] = now; - Read(); +#ifdef OUTTA_CACHE + { + int fd; + char fn[64]; + sprintf(fn, "cache/" MYHOSTNAME ".b%d", currpid); + if( (fd = open(fn, O_WRONLY | O_CREAT, 0600)) < 0 ) + abort_bbs(0); + write(fd, nbrd, nbrdlength); + close(fd); + free(nbrd); +#endif + Read(); +#ifdef OUTTA_CACHE + if( (fd = open(fn, O_RDONLY)) < 0 ) + abort_bbs(0); + nbrd = (boardstat_t *) malloc(nbrdlength); + read(fd, nbrd, nbrdlength); + close(fd); + unlink(fn); + } +#endif check_newpost(ptr); head = -1; setutmpmode(newflag ? READNEW : READBRD); -- cgit v1.2.3