summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c12
-rw-r--r--mbbsd/cache.c79
-rw-r--r--mbbsd/read.c50
3 files changed, 14 insertions, 127 deletions
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: 順便更新一下cache */
- 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: 這裡應該改成用reference的方式取得原來的檔案 */
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增進效率 */
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;