summaryrefslogtreecommitdiffstats
path: root/mbbsd/cache.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-06 16:15:57 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-06 16:15:57 +0800
commit9e31813bc81a55a2cde55ae365d4c0f6f6eac23f (patch)
treeb7067628a081a20d781abbe73c48090224c718c6 /mbbsd/cache.c
parent2d14720ed4ca63e091e25073d3a147479abfe7f3 (diff)
downloadpttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.tar
pttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.tar.gz
pttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.tar.bz2
pttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.tar.lz
pttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.tar.xz
pttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.tar.zst
pttbbs-9e31813bc81a55a2cde55ae365d4c0f6f6eac23f.zip
if SHM->Bbusystate is true in bcache_reload, wait at most 10 secs
then ignore the lock and do bcache_reload. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2386 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/cache.c')
-rw-r--r--mbbsd/cache.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 6c81ce00..5ac60128 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -546,27 +546,27 @@ sort_bcache(void)
void
reload_bcache(void)
{
- if (SHM->Bbusystate) {
- safe_sleep(1);
+ int i, fd;
+ for( i = 0 ; i < 10 && SHM->Bbusystate ; ++i ){
+ printf("SHM->Bbusystate is currently locked (value: %d). "
+ "please wait... ", SHM->Bbusystate);
+ sleep(1);
}
- else {
- int fd;
- SHM->Bbusystate = 1;
- if ((fd = open(fn_board, O_RDONLY)) > 0) {
- SHM->Bnumber =
- read(fd, bcache, MAX_BOARD * sizeof(boardheader_t)) /
- sizeof(boardheader_t);
- close(fd);
- }
- memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time_t));
- memset(SHM->total, 0, MAX_BOARD * sizeof(int));
- /* 等所有 boards 資料更新後再設定 uptime */
- SHM->Buptime = SHM->Btouchtime;
- log_usies("CACHE", "reload bcache");
- SHM->Bbusystate = 0;
- sort_bcache();
+ SHM->Bbusystate = 1;
+ if ((fd = open(fn_board, O_RDONLY)) > 0) {
+ SHM->Bnumber =
+ read(fd, bcache, MAX_BOARD * sizeof(boardheader_t)) /
+ sizeof(boardheader_t);
+ close(fd);
}
+ memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time_t));
+ memset(SHM->total, 0, MAX_BOARD * sizeof(int));
+ /* 等所有 boards 資料更新後再設定 uptime */
+ SHM->Buptime = SHM->Btouchtime;
+ log_usies("CACHE", "reload bcache");
+ SHM->Bbusystate = 0;
+ sort_bcache();
}
void resolve_boards(void)