diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-12-07 19:48:42 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-12-07 19:48:42 +0800 |
commit | e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2 (patch) | |
tree | 6917e3ead4beec72534673b799b5e51add0a0519 /mbbsd/bbs.c | |
parent | f596ac6e290311dea6c2181816b7d096127696a8 (diff) | |
download | pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.tar pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.tar.gz pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.tar.bz2 pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.tar.lz pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.tar.xz pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.tar.zst pttbbs-e67dbfb410cb519dbd4ae3e0f3cd12aef46e48f2.zip |
use open() instead of fopen() in log_file()
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1405 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/bbs.c')
-rw-r--r-- | mbbsd/bbs.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 8d1f4aca..a0385552 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -29,9 +29,9 @@ anticrosspost() char buf[200]; snprintf(buf, sizeof(buf), - "\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m", + "\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m\n", cuser.userid, ctime(&now)); - log_file("etc/illegal_money", buf); + log_file("etc/illegal_money", buf, 1); post_violatelaw(cuser.userid, "Ptt系統警察", "Cross-post", "罰單處份"); cuser.userlevel |= PERM_VIOLATELAW; @@ -1465,13 +1465,19 @@ do_add_recommend(char *direct, fileheader_t *fhdr, int ent, char *buf) { char path[256]; int fd; + /* + race here: + 為了減少 system calls , 現在直接用當前的推文數 +1 寫入 .DIR 中. + 造成 + 1.若該文檔名被換掉的話, 推文將寫至舊檔名中 (造成幽靈檔) + 2.沒有重新讀一次, 所以推文數可能被少算 + 3.若推的時候前文被刪, 將加到後文的推文數 + */ setdirpath(path, direct, fhdr->filename); - if( (fd = open(path, O_WRONLY | O_APPEND)) < 0 ){ // 只 APPEND, 不 CREAT + if( log_file(path, buf, 0) == -1 ){ // 不 CREATE vmsg("推薦/競標失敗"); return -1; } - write(fd, buf, strlen(buf)); - close(fd); if( fhdr->recommend < 100 ){ fileheader_t t; @@ -2542,9 +2548,9 @@ log_board(char *mode, time_t usetime) char buf[256]; if (usetime > 30) { - snprintf(buf, sizeof(buf), "USE %-20.20s Stay: %5ld (%s) %s", + snprintf(buf, sizeof(buf), "USE %-20.20s Stay: %5ld (%s) %s\n", mode, usetime, cuser.userid, ctime(&now)); - log_file(FN_USEBOARD, buf); + log_file(FN_USEBOARD, buf, 1); } } #endif |