diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-01-18 17:13:53 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-01-18 17:13:53 +0800 |
commit | 5a0e612ca4825c5b35acf82d142fd7d7e745e1d0 (patch) | |
tree | 0f13deee81f1f569c8dc13cc3f686299c41f2ed3 /mbbsd/record.c | |
parent | 519c7a330f916c29c21ef80d2fc20326e7ba96e2 (diff) | |
download | pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.tar pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.tar.gz pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.tar.bz2 pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.tar.lz pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.tar.xz pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.tar.zst pttbbs-5a0e612ca4825c5b35acf82d142fd7d7e745e1d0.zip |
fix the bug of the cost of deleting post
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3475 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r-- | mbbsd/record.c | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c index 7a2fc429..c58b7ecc 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -132,41 +132,13 @@ substitute_record(const char *fpath, const void *rptr, int size, int id) return 0; } -int -substitute_ref_record(const char *direct, fileheader_t * fhdr, int ent) -{ - fileheader_t hdr; - char fname[PATHLEN]; - int num = 0; - - /* rocker.011018: 串接模式用reference增進效率 */ - if (!(fhdr->filemode & FILE_BOTTOM) && (fhdr->multi.refer.flag) && - (num = fhdr->multi.refer.ref)){ - setdirpath(fname, direct, ".DIR"); - get_record(fname, &hdr, sizeof(hdr), num); - if (strcmp(hdr.filename, fhdr->filename)) { - if((num = getindex(fname, fhdr, num))>0) { - substitute_record(fname, fhdr, sizeof(*fhdr), num); - } - } - else if(num>0) { - fhdr->multi.money = hdr.multi.money; - substitute_record(fname, fhdr, sizeof(*fhdr), num); - } - fhdr->multi.refer.flag = 1; - fhdr->multi.refer.ref = num; // Ptt: update now! - } - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - return num; -} - /* return index>0 if thisstamp==stamp[index], * return -index<0 if stamp[index-1]<thisstamp<stamp[index+1], XXX thisstamp ?<>? stamp[index] * or XXX filename[index]="" * return 0 if error */ int -getindex(const char *direct, fileheader_t *fhdr, int end) +getindex_m(const char *direct, fileheader_t *fhdr, int end, int isloadmoney) { // Ptt: 從前面找很費力 太暴力 int fd = -1, begin = 1, i, s, times, stamp; fileheader_t fh; @@ -186,7 +158,8 @@ getindex(const char *direct, fileheader_t *fhdr, int end) end = i - 1; else if( s == stamp ){ close(fd); - fhdr->multi.money = fh.multi.money; + if(isloadmoney) + fhdr->multi.money = fh.multi.money; return i; } else @@ -203,6 +176,40 @@ getindex(const char *direct, fileheader_t *fhdr, int end) return 0; } +inline int +getindex(const char *direct, fileheader_t *fhdr, int end) +{ + return getindex_m(direct, fhdr, end, 0); +} + +int +substitute_ref_record(const char *direct, fileheader_t * fhdr, int ent) +{ + fileheader_t hdr; + char fname[PATHLEN]; + int num = 0; + + /* rocker.011018: 串接模式用reference增進效率 */ + if (!(fhdr->filemode & FILE_BOTTOM) && (fhdr->multi.refer.flag) && + (num = fhdr->multi.refer.ref)){ + setdirpath(fname, direct, ".DIR"); + get_record(fname, &hdr, sizeof(hdr), num); + if (strcmp(hdr.filename, fhdr->filename)) { + if((num = getindex_m(fname, fhdr, num, 1))>0) { + substitute_record(fname, fhdr, sizeof(*fhdr), num); + } + } + else if(num>0) { + fhdr->multi.money = hdr.multi.money; + substitute_record(fname, fhdr, sizeof(*fhdr), num); + } + fhdr->multi.refer.flag = 1; + fhdr->multi.refer.ref = num; // Ptt: update now! + } + substitute_record(direct, fhdr, sizeof(*fhdr), ent); + return num; +} + /* rocker.011022: 避免lock檔開啟時不正常斷線,造成永久lock */ #ifndef _BBS_UTIL_C_ |