diff options
Diffstat (limited to 'mbbsd/cache.c')
-rw-r--r-- | mbbsd/cache.c | 38 |
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; } |