summaryrefslogtreecommitdiffstats
path: root/mbbsd/cache.c
diff options
context:
space:
mode:
authorjack <jack@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-03 05:58:08 +0800
committerjack <jack@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-03 05:58:08 +0800
commite443776eb7025c569df22f801965f0ec84798e35 (patch)
treea6200d5ccc57109dfece0b30180da83a9915785c /mbbsd/cache.c
parent886fd091d3cc9e39e342e13e994fb63acb30c34b (diff)
downloadpttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar
pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.gz
pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.bz2
pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.lz
pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.xz
pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.zst
pttbbs-e443776eb7025c569df22f801965f0ec84798e35.zip
merge trunk to branches and corrected confliction
git-svn-id: http://opensvn.csie.org/pttbbs/branches/Jaky.i18n@1919 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/cache.c')
-rw-r--r--mbbsd/cache.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index d35b0839..2569a45f 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -471,13 +471,9 @@ setutmpmode(unsigned int mode)
{
if (currstat != mode)
currutmp->mode = currstat = mode;
-
/* 追蹤使用者 */
if (HAS_PERM(PERM_LOGUSER)) {
- char msg[200];
- snprintf(msg, sizeof(msg), "%s setutmpmode to %s(%d) at %s",
- cuser.userid, modestring(currutmp, 0), mode, Cdate(&COMMON_TIME));
- log_user(msg);
+ log_user("setutmpmode to %s(%d)", modestring(currutmp, 0), mode);
}
}
#endif
@@ -504,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];
}
@@ -516,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
@@ -525,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) {
@@ -538,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();
}
}
@@ -571,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)
@@ -589,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 */
@@ -628,6 +625,9 @@ setbottomtotal(int bid)
n = get_num_records(genbuf, sizeof(fileheader_t));
if(n>5)
{
+#ifdef DEBUG_BOTTOM
+ log_file("fix_bottom", 1, "%s n:%d\n", genbuf, n);
+#endif
unlink(genbuf);
SHM->n_bottom[bid-1]=0;
}