summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-14 19:41:27 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-14 19:41:27 +0800
commitd08db5565702465469052e01d06ff76194d03cd4 (patch)
tree58db90bc271d5f58bdc0c75b7efd3a8228e93a68
parent115cf628efd96f27a9f8b4379e1b87b31293921f (diff)
downloadpttbbs-d08db5565702465469052e01d06ff76194d03cd4.tar
pttbbs-d08db5565702465469052e01d06ff76194d03cd4.tar.gz
pttbbs-d08db5565702465469052e01d06ff76194d03cd4.tar.bz2
pttbbs-d08db5565702465469052e01d06ff76194d03cd4.tar.lz
pttbbs-d08db5565702465469052e01d06ff76194d03cd4.tar.xz
pttbbs-d08db5565702465469052e01d06ff76194d03cd4.tar.zst
pttbbs-d08db5565702465469052e01d06ff76194d03cd4.zip
remove dircache
prevent error for push bottom git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1758 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/pttstruct.h4
-rw-r--r--mbbsd/bbs.c12
-rw-r--r--mbbsd/cache.c79
-rw-r--r--mbbsd/read.c50
4 files changed, 14 insertions, 131 deletions
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 20260ad1..48c35d49 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -376,10 +376,6 @@ typedef struct {
unsigned char nHOTs;
boardheader_t *HBcache[HOTBOARDCACHE];
#endif
-#if DIRCACHESIZE
- // Ptt: dricache À³³§ï令¨¥ucache ¼öö­Ìªùù¬Ýݪ©©Á×קKmemory®öö¶O
- fileheader_t dircache[MAX_BOARD][DIRCACHESIZE];
-#endif
time_t busystate_b[MAX_BOARD];
int total[MAX_BOARD];
unsigned char n_bottom[MAX_BOARD]; /* number of bottom */
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index de6a385a..f1e09eaf 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -948,7 +948,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct)
fileheader_t postfile;
boardheader_t *bp = getbcache(currbid);
- if (strcmp(bp->brdname, "Security") == 0)
+ if (fhdr->filemode&FILE_BOTTOM && strcmp(bp->brdname, "Security") == 0)
return DONOTHING;
if (!HAS_PERM(PERM_SYSOP) && ((bp->brdattr & BRD_VOTEBOARD) || fhdr->filemode & FILE_VOTE))
@@ -1011,9 +1011,6 @@ edit_post(int ent, fileheader_t * fhdr, char *direct)
strlcpy(fhdr->title, save_title, sizeof(fhdr->title));
brc_addlist(postfile.filename);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- /* rocker.011018: ¶¶«K§ó·s¤@¤Ucache */
- touchdircache(currbid);
-
if (!(currbrdattr & BRD_HIDE) && (!bp->level || (currbrdattr & BRD_POSTMASK)))
do_crosspost(ALLPOST, fhdr, fpath);
}
@@ -1444,7 +1441,6 @@ edit_title(int ent, fileheader_t * fhdr, char *direct)
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
/* rocker.011018: ³o¸ÌÀ³¸Ó§ï¦¨¥Îreferenceªº¤è¦¡¨ú±o­ì¨ÓªºÀÉ®× */
substitute_check(fhdr);
- touchdircache(currbid);
}
return FULLUPDATE;
}
@@ -1457,7 +1453,6 @@ solve_post(int ent, fileheader_t * fhdr, char *direct)
if (HAS_PERM(PERM_SYSOP)) {
fhdr->filemode ^= FILE_SOLVED;
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- touchdircache(currbid);
return PART_REDRAW;
}
return DONOTHING;
@@ -1481,7 +1476,6 @@ recommend_cancel(int ent, fileheader_t * fhdr, char *direct)
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
substitute_check(fhdr);
- touchdircache(currbid);
return FULLUPDATE;
}
static int
@@ -1519,7 +1513,6 @@ do_add_recommend(char *direct, fileheader_t *fhdr, int ent, char *buf)
write(fd, &fhdr->recommend, sizeof(char));
close(fd);
- touchdircache(currbid);
}
return 0;
}
@@ -1762,7 +1755,6 @@ mark_post(int ent, fileheader_t * fhdr, char *direct)
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
substitute_check(fhdr);
- touchdircache(currbid);
return PART_REDRAW;
}
@@ -2346,7 +2338,6 @@ push_bottom(int ent, fileheader_t * fhdr, char *direct)
num = delete_record(direct, sizeof(fileheader_t), ent);
}
setbottomtotal(currbid);
- touchdircache(currbid);
return DIRCHANGED;
}
@@ -2415,7 +2406,6 @@ good_post(int ent, fileheader_t * fhdr, char *direct)
}
}
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- touchdircache(currbid);
/* rocker.011018: ¦ê±µ¼Ò¦¡¥Îreference¼W¶i®Ä²v */
if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) {
fileheader_t hdr;
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 0d551669..0d542ba5 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -507,80 +507,6 @@ void touchbtotal(int bid) {
SHM->lastposttime[bid - 1] = 0;
}
-void
-touchdircache(int bid)
-{
-#if DIRCACHESIZE
- int *i = (int *)&SHM->dircache[bid - 1][0].filename[0];
- *i = 0;
-#endif
-}
-
-#if DIRCACHESIZE
-void
-load_fileheader_bottom_cache(int bid, char *bottompath)
-{
- int num = getbtotal(bid), n_bottom = getbottomtotal(bid);
- int n = num - DIRCACHESIZE + n_bottom + 1;
- int dirsize = DIRCACHESIZE-n_bottom;
- if (n<1)
- {
- n=1;
- dirsize=num;
- }
- if(n_bottom)
- {
- get_records(bottompath, &SHM->dircache[bid - 1][dirsize],
- sizeof(fileheader_t), 1, n_bottom);
- }
-}
-void
-load_fileheader_cache(int bid, char *direct)
-{
- int num = getbtotal(bid), n_bottom = getbottomtotal(bid);
- int n = num - DIRCACHESIZE + n_bottom + 1;
- int dirsize = DIRCACHESIZE-n_bottom;
- if (n<1)
- {
- n=1;
- dirsize=num;
- }
- if (SHM->Bbusystate != 1 && COMMON_TIME - SHM->busystate_b[bid - 1] >= 10) {
- SHM->busystate_b[bid - 1] = COMMON_TIME;
- get_records(direct, SHM->dircache[bid - 1],
- sizeof(fileheader_t), n, dirsize);
- SHM->busystate_b[bid - 1] = 0;
- } else {
- safe_sleep(1);
- }
-}
-
-int
-get_fileheader_cache(int bid, char *direct, fileheader_t * headers,
- int recbase, int nlines)
-{
- int ret, n, num;
-
- num = getbtotal(bid)+getbottomtotal(bid);
-
- ret = num - recbase + 1,
- n = (num - DIRCACHESIZE + 1);
-
-
- if (SHM->dircache[bid - 1][0].filename[0] == '\0')
- load_fileheader_cache(bid, direct);
- if (n < 1)
- n = recbase - 1;
- else
- n = recbase - n;
- if (n < 0)
- n = 0;
- if (ret > nlines)
- ret = nlines;
- memcpy(headers, &(SHM->dircache[bid - 1][n]), sizeof(fileheader_t) * ret);
- return ret;
-}
-#endif
static int
cmpboardname(boardheader_t ** brd, boardheader_t ** tmp)
@@ -731,9 +657,6 @@ setbottomtotal(int bid)
char genbuf[256];
setbfile(genbuf, bh->brdname, ".DIR.bottom");
SHM->n_bottom[bid-1]=get_num_records(genbuf, sizeof(fileheader_t));
-#if DIRCACHESIZE
- load_fileheader_bottom_cache(currbid, genbuf);
-#endif
}
void
setbtotal(int bid)
@@ -758,8 +681,6 @@ setbtotal(int bid)
} else
SHM->lastposttime[bid - 1] = 0;
close(fd);
- if (num)
- touchdircache(bid);
}
void
diff --git a/mbbsd/read.c b/mbbsd/read.c
index a0302cdf..55a446c8 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -896,29 +896,13 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey
recbase = 1;
locmem->top_ln = recbase;
}
-#if DIRCACHESIZE
- if( bidcache > 0 &&
- !(currmode & (MODE_SELECT | MODE_DIGEST)))
- {
- if((last_line - recbase) < DIRCACHESIZE )
- entries = get_fileheader_cache(currbid, currdirect,
- headers, recbase, p_lines);
- else
- entries += get_records(currdirect, headers, FHSZ,
- recbase, p_lines);
- }
- else
-#endif
- {
- entries = get_records(currdirect, headers, FHSZ, recbase,
+ if(recbase <= bottom_line)
+ entries = get_records(currdirect, headers, FHSZ, recbase,
p_lines);
- if( entries>=0 && entries<p_lines && n_bottom)
- entries +=get_records(directbottom,&headers[entries],FHSZ,
- 1, p_lines-entries);
- }
-
-
-
+ if( entries>=0 && entries<p_lines && n_bottom)
+ entries +=get_records(directbottom,&headers[entries],FHSZ,
+ recbase<=bottom_line ? 1 : recbase-bottom_line,
+ p_lines-entries);
}
if (locmem->crs_ln > last_line)
locmem->crs_ln = last_line;
@@ -1000,21 +984,13 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey
} else if (reload) {
recbase = locmem->top_ln;
-#if DIRCACHESIZE
- if (bidcache > 0 && !(currmode & (MODE_SELECT | MODE_DIGEST))
- && last_line - recbase < DIRCACHESIZE)
- entries = get_fileheader_cache(currbid, currdirect,
- headers, recbase, p_lines);
- else
-#endif
- {
- sprintf(directbottom, "%s.bottom", direct);
- entries = get_records(currdirect, headers, FHSZ, recbase,
- p_lines);
- if( entries>=0 && entries<p_lines && n_bottom)
- entries+=get_records(directbottom,&headers[entries],FHSZ,
- 1, p_lines-entries);
- }
+ if(recbase <= bottom_line)
+ entries = get_records(currdirect, headers, FHSZ, recbase,
+ p_lines);
+ if( entries>=0 && entries<p_lines && n_bottom)
+ entries +=get_records(directbottom,&headers[entries],FHSZ,
+ recbase<=bottom_line ? 1 : recbase-bottom_line,
+ p_lines-entries);
}
num = locmem->crs_ln - locmem->top_ln;