summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-12 22:53:40 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-12 22:53:40 +0800
commit099fe68dba55361c8e3520af05a64c2a4a369501 (patch)
treedee1130894f68fce1af0f523617a067f4c5bcb55
parente62883ad4fbaf62cc162be1ee5eb75358044beda (diff)
downloadpttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.tar
pttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.tar.gz
pttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.tar.bz2
pttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.tar.lz
pttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.tar.xz
pttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.tar.zst
pttbbs-099fe68dba55361c8e3520af05a64c2a4a369501.zip
read/write recommend with same fd,
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1963 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 50094bd3..45a4cfe9 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1336,15 +1336,18 @@ do_add_recommend(char *direct, fileheader_t *fhdr, int ent, char *buf, int type)
if( update ){
int fd;
- get_record(direct, fhdr, sizeof(fhdr), ent);
- fhdr->recommend += update;
//Ptt: update only necessary
- if( (fd = open(direct, O_WRONLY)) < 0 )
+ if( (fd = open(direct, O_RDWR)) < 0 )
return -1;
if( lseek(fd, (off_t)(sizeof(fileheader_t) * (ent - 1) +
(int)&fhdr->recommend - (int)fhdr), SEEK_SET) >= 0)
// 如果 lseek 失敗就不會 write
+ {
+ read(fd, &fhdr->recommend, sizeof(char));
+ fhdr->recommend += update;
+ lseek(fd, -1, SEEK_CUR);
write(fd, &fhdr->recommend, sizeof(char));
+ }
close(fd);
}