diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-03-26 02:10:40 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-03-26 02:10:40 +0800 |
commit | bf4070a6faae8677eb551afb430dd3d3f0e04a66 (patch) | |
tree | dce8ed6725cc41d9257ed2ec30a5e2b6eca807bd | |
parent | 9c4346e8ebea6e1e8086e30760f0d034862de151 (diff) | |
download | pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.tar pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.tar.gz pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.tar.bz2 pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.tar.lz pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.tar.xz pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.tar.zst pttbbs-bf4070a6faae8677eb551afb430dd3d3f0e04a66.zip |
* Only write fav to disk when really dirty. To reduce heavy load of mass logout after peak hour.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3494 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/fav.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 63e74527..eb9a40dc 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -271,6 +271,32 @@ inline int valid_item(fav_type_t *ft){ return ft->attr & FAVH_FAV; } +static int is_need_rebuild_fav(fav_t *fp) +{ + int i, nData; + fav_type_t *ft; + + nData = fp->DataTail; + + for (i = 0; i < nData; i++){ + if (!valid_item(&fp->favh[i])) + return 1; + + ft = &fp->favh[i]; + switch (get_item_type(ft)){ + case FAVT_BOARD: + case FAVT_LINE: + break; + case FAVT_FOLDER: + if(is_need_rebuild_fav(get_fav_folder(&fp->favh[i]))) + return 1; + break; + default: + return 1; + } + } + return 0; +} /** * 清除 fp(dir) 中無效的 entry/dir。「無效」指的是沒有 FAVH_FAV flag,所以 * 不包含不存在的看板。 @@ -311,7 +337,8 @@ static void rebuild_fav(fav_t *fp) inline void fav_cleanup(void) { - rebuild_fav(get_fav_root()); + if (is_need_rebuild_fav(get_fav_root())) + rebuild_fav(get_fav_root()); } /* sort the fav */ @@ -504,6 +531,7 @@ int fav_load(void) read_favrec(frp, fp); fav_stack_push_fav(fp); fclose(frp); + dirty = 0; return 0; } |