diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-18 21:35:47 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-18 21:35:47 +0800 |
commit | c3403048ab4f47341514d1e37f06984f441cae76 (patch) | |
tree | 92cdf15705a648d350707479a24979bc39f64261 /mbbsd | |
parent | 20a5d27b9cd5b01182535ec3316b395b9db11eaf (diff) | |
download | pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.tar pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.tar.gz pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.tar.bz2 pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.tar.lz pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.tar.xz pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.tar.zst pttbbs-c3403048ab4f47341514d1e37f06984f441cae76.zip |
background load bottom after sort_bcache() or damage whole system,
especially sites with large number of boards or slow hdds.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2519 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/cache.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c index c29f3a42..469acc46 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -540,6 +540,7 @@ void reload_bcache(void) { int i, fd; + pid_t pid; for( i = 0 ; i < 10 && SHM->Bbusystate ; ++i ){ printf("SHM->Bbusystate is currently locked (value: %d). " "please wait... ", SHM->Bbusystate); @@ -556,6 +557,16 @@ reload_bcache(void) memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time4_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(); + + printf("load bottom in background"); + if( (pid = fork()) > 0 ) + return; + setproctitle("loading bottom"); for( i = 0 ; i < MAX_BOARD ; ++i ) if( SHM->bcache[i].brdname[0] ){ char fn[128]; @@ -568,12 +579,9 @@ reload_bcache(void) n = 5; SHM->n_bottom[i] = n; } - - /* 等所有 boards 資料更新後再設定 uptime */ - SHM->Buptime = SHM->Btouchtime; - log_usies("CACHE", "reload bcache"); - SHM->Bbusystate = 0; - sort_bcache(); + if( pid == 0 ) + exit(0); + // if pid == -1 should be returned } void resolve_boards(void) |