summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/admin.c4
-rw-r--r--mbbsd/board.c1
-rw-r--r--mbbsd/cache.c29
-rw-r--r--mbbsd/read.c2
4 files changed, 21 insertions, 15 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 6e98ff2e..e828e3f3 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -263,6 +263,7 @@ void delete_symbolic_link(boardheader_t *bh, int bid)
memset(bh, 0, sizeof(boardheader_t));
substitute_record(fn_board, bh, sizeof(boardheader_t), bid);
reset_board(bid);
+ sort_bcache();
log_usies("DelLink", bh->brdname);
}
@@ -361,6 +362,7 @@ m_mod_board(char *bname)
post_msg("Security", bh.title, "請注意刪除的合法性", "[系統安全局]");
substitute_record(fn_board, &bh, sizeof(bh), bid);
reset_board(bid);
+ sort_bcache();
log_usies("DelBoard", bh.title);
outs("刪板完畢");
}
@@ -448,6 +450,7 @@ m_mod_board(char *bname)
setup_man(&newbh);
substitute_record(fn_board, &newbh, sizeof(newbh), bid);
reset_board(bid);
+ sort_bcache();
log_usies("SetBoard", newbh.brdname);
}
}
@@ -607,6 +610,7 @@ static int add_board_record(boardheader_t *board)
if ((bid = getbnum("")) > 0) {
substitute_record(fn_board, board, sizeof(boardheader_t), bid);
reset_board(bid);
+ sort_bcache();
} else if (append_record(fn_board, (fileheader_t *)board, sizeof(boardheader_t)) == -1) {
return -1;
} else {
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 34cbef5d..f18c6d50 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -591,6 +591,7 @@ paste_taged_brds(int gid)
log_usies("SetBoardGID", bh->brdname);
}
}
+ sort_bcache();
return 1;
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index a1088160..c78dbed4 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -500,11 +500,15 @@ cmpboardclass(boardheader_t ** brd, boardheader_t ** tmp)
strcasecmp((*brd)->brdname, (*tmp)->brdname);
}
-static void
+void
sort_bcache(void)
{
int i;
- /* critical section 不能單獨呼叫 呼叫reload_bcache or reset_board */
+ /* critical section 盡量不要呼叫 */
+ /* 只有新增 或移除看板 需要呼叫到 */
+ if(SHM->Bbusystate)
+ { sleep(1); return; }
+ SHM->Bbusystate = 1;
for (i = 0; i < SHM->Bnumber; i++) {
SHM->bsorted[1][i] = SHM->bsorted[0][i] = &bcache[i];
}
@@ -512,6 +516,12 @@ sort_bcache(void)
(QCAST) cmpboardname);
qsort(SHM->bsorted[1], SHM->Bnumber, sizeof(boardheader_t *),
(QCAST) cmpboardclass);
+
+ for (i = 0; i < SHM->Bnumber; i++) {
+ bcache[i].firstchild[0] = NULL;
+ bcache[i].firstchild[1] = NULL;
+ }
+ SHM->Bbusystate = 0;
}
void
@@ -521,7 +531,7 @@ reload_bcache(void)
safe_sleep(1);
}
else {
- int fd, i;
+ int fd;
SHM->Bbusystate = 1;
if ((fd = open(fn_board, O_RDONLY)) > 0) {
@@ -534,12 +544,8 @@ reload_bcache(void)
/* 等所有 boards 資料更新後再設定 uptime */
SHM->Buptime = SHM->Btouchtime;
log_usies("CACHE", "reload bcache");
- sort_bcache();
- for (i = 0; i < SHM->Bnumber; ++i) {
- bcache[i].firstchild[0] = NULL;
- bcache[i].firstchild[1] = NULL;
- }
SHM->Bbusystate = 0;
+ sort_bcache();
}
}
@@ -567,7 +573,7 @@ void addbrd_touchcache(void)
void
reset_board(int bid) /* XXXbid: from 1 */
{ /* Ptt: 這樣就不用老是touch board了 */
- int fd, i, nuser;
+ int fd, nuser;
boardheader_t *bhdr;
if (--bid < 0)
@@ -585,11 +591,6 @@ reset_board(int bid) /* XXXbid: from 1 */
read(fd, bhdr, sizeof(boardheader_t));
close(fd);
}
- sort_bcache();
- for (i = 0; i < SHM->Bnumber; i++) {
- bcache[i].firstchild[0] = NULL;
- bcache[i].firstchild[1] = NULL;
- }
SHM->busystate_b[bid] = 0;
buildBMcache(bid + 1); /* XXXbid */
diff --git a/mbbsd/read.c b/mbbsd/read.c
index ea8dd169..ce6205cd 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -381,7 +381,7 @@ select_read(keeploc_t * locmem, int sr_mode)
else
setbfile(newdirect, currboard, genbuf);
- if( now - dasht(newdirect) < 1200 )
+ if( now - dasht(newdirect) < 3600 )
count = dashs(newdirect);
else {
if( (fd = open(newdirect, O_CREAT | O_RDWR, 0600)) == -1 )