diff options
author | clkao <clkao@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-11-10 17:50:37 +0800 |
---|---|---|
committer | clkao <clkao@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-11-10 17:50:37 +0800 |
commit | 553f62b46924ccc4b570605bbb59a4e25e006f9b (patch) | |
tree | 3f343eb187fe0c0170586a6c48176318b63e74b9 | |
parent | e6939afc8c019bbaf7fc38334df865701eb1bd99 (diff) | |
download | pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.tar pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.tar.gz pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.tar.bz2 pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.tar.lz pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.tar.xz pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.tar.zst pttbbs-553f62b46924ccc4b570605bbb59a4e25e006f9b.zip |
cpustats for dorecommend
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5238 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/statistic.h | 3 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbs.c | 15 | ||||
-rw-r--r-- | pttbbs/util/shmctl.c | 3 |
3 files changed, 17 insertions, 4 deletions
diff --git a/pttbbs/include/statistic.h b/pttbbs/include/statistic.h index 6213ae91..fdc43382 100644 --- a/pttbbs/include/statistic.h +++ b/pttbbs/include/statistic.h @@ -71,6 +71,9 @@ enum { // XXX description in shmctl.c STAT_BOARDREC, STAT_BOARDREC_SCPU, STAT_BOARDREC_UCPU, + STAT_DORECOMMEND, + STAT_DORECOMMEND_SCPU, + STAT_DORECOMMEND_UCPU, /* insert here. don't forget update shmctl.c */ STAT_NUM, STAT_MAX=512 diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index 8aee0c88..4534b562 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -2622,6 +2622,8 @@ do_add_recommend(const char *direct, fileheader_t *fhdr, char path[PATHLEN]; int update = 0; int fd; + BEGINSTAT(STAT_DORECOMMEND); + /* race here: 為了減少 system calls , 現在直接用當前的推文數 +1 寫入 .DIR 中. @@ -2659,7 +2661,7 @@ do_add_recommend(const char *direct, fileheader_t *fhdr, close(fd); if (!lock_success) { vmsg("錯誤: 檔案正被它人編輯中,無法寫入。"); - return -1; + goto error; } #else write(fd, buf, strlen(buf)); @@ -2667,7 +2669,7 @@ do_add_recommend(const char *direct, fileheader_t *fhdr, #endif } else { vmsg("錯誤: 原檔案已被刪除。 無法寫入。"); - return -1; + goto error; } // XXX do lock some day! @@ -2688,12 +2690,17 @@ do_add_recommend(const char *direct, fileheader_t *fhdr, { if (modify_dir_lite(direct, ent, fhdr->filename, fhdr->modified, NULL, update) < 0) - return -1; + goto error; // mark my self as "read this file". brc_addlist(fhdr->filename, fhdr->modified); } - + + ENDSTAT(STAT_DORECOMMEND); return 0; + + error: + ENDSTAT(STAT_DORECOMMEND); + return -1; } int diff --git a/pttbbs/util/shmctl.c b/pttbbs/util/shmctl.c index 26e81e93..a3c28131 100644 --- a/pttbbs/util/shmctl.c +++ b/pttbbs/util/shmctl.c @@ -1137,6 +1137,9 @@ int showstat(int argc, char *argv[]) "STAT_BOARDREC", "STAT_BOARDREC_SCPU", "STAT_BOARDREC_UCPU", + "STAT_DORECOMMEND", + "STAT_DORECOMMEND_SCPU", + "STAT_DORECOMMEND_UCPU", }; if(argv[1] && strcmp(argv[1],"-c")==0) |