diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-04-08 22:20:03 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-04-08 22:20:03 +0800 |
commit | abd9d4e39f7294a9006fad1b5907276de45146c6 (patch) | |
tree | b43e5a3d523ff83ed3f719f787127f8f4f8a7e8d /mbbsd | |
parent | 16cc4b8824babdc2d18c7c70cd1c6ea612dd5ee0 (diff) | |
download | pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.tar pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.tar.gz pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.tar.bz2 pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.tar.lz pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.tar.xz pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.tar.zst pttbbs-abd9d4e39f7294a9006fad1b5907276de45146c6.zip |
make different tmp file to avoid open same file for write.
(however, open with "w" flag will write to different inode, so won't make things corruption)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3323 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/brc.c | 3 | ||||
-rw-r--r-- | mbbsd/fav.c | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/mbbsd/brc.c b/mbbsd/brc.c index d32e989b..f30bef17 100644 --- a/mbbsd/brc.c +++ b/mbbsd/brc.c @@ -321,8 +321,7 @@ brc_finalize(){ int ok=0; brc_update(); setuserfile(brcfile, fn_brc); - setuserfile(tmpfile, fn_brc); - strlcat(tmpfile, ".tmp", sizeof(tmpfile)); + snprintf(tmpfile, sizeof(tmpfile), "%s.tmp.%x", brcfile, getpid()); if (brc_buf != NULL && (fd = open(tmpfile, O_WRONLY | O_CREAT | O_TRUNC, 0644)) != -1) { if(write(fd, brc_buf, brc_size)==brc_size) diff --git a/mbbsd/fav.c b/mbbsd/fav.c index a1f2336a..bf1c7b7e 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -582,8 +582,8 @@ int fav_save(void) if (!dirty) return 0; - setuserfile(buf, FAV4".tmp"); setuserfile(buf2, FAV4); + snprintf(buf, sizeof(buf), "%s.tmp.%x",buf2, getpid()); fwp = fopen(buf, "w"); if(fwp == NULL) return -1; |