summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-26 19:00:19 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-26 19:00:19 +0800
commitaa516702616632a2d5a7e634017c3e5845440f6a (patch)
tree43358a20cc7b019353f8e4537be25190651d3c50
parent76c1071aa3ccb4deb24924b3e39123379fb9da5b (diff)
downloadpttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.tar
pttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.tar.gz
pttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.tar.bz2
pttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.tar.lz
pttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.tar.xz
pttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.tar.zst
pttbbs-aa516702616632a2d5a7e634017c3e5845440f6a.zip
* badpost can be only assigned if the file deletion was success, to prevent race condition.
* note: note good implementation anyway, but we'd like to minimize the change for this issue. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4702 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 3b1a4eb9..17a4c3ab 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -508,7 +508,10 @@ readdoent(int num, fileheader_t * ent)
} // if(!iscorpse)
else {
// quick display
- prints(ANSI_COLOR(1;30) "%7d ", num);
+#ifdef USE_PFTERM
+ outs(ANSI_COLOR(1;30));
+#endif
+ prints("%7d ", num);
prints("%-6.5s", ent->date);
prints("%-13.12s", ent->owner);
prints("╳ %-.*s" ANSI_RESET "\n",
@@ -668,7 +671,7 @@ outgo_post(const fileheader_t *fh, const char *board, const char *userid, const
}
}
-static void
+static int
cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
{
FILE *fin, *fout;
@@ -677,8 +680,9 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
char genbuf[200];
char nick[STRLEN], fn1[PATHLEN];
int len = 42-strlen(currboard);
+ int ret = -1;
- if(!fh->filename[0]) return;
+ if(!fh->filename[0]) return ret;
setbfile(fn1, currboard, fh->filename);
if ((fin = fopen(fn1, "r"))) {
brd = by_BM ? BN_DELETED : BN_JUNK;
@@ -710,11 +714,12 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
fclose(fin);
log_filef(fn1, LOG_CREAT, "\n※ Deleted by: %s (%s) %s",
cuser.userid, fromhost, Cdatelite(&now));
- Rename(fn1, newpath);
+ ret = Rename(fn1, newpath);
setbdir(genbuf, brd);
append_record(genbuf, &postfile, sizeof(postfile));
setbtotal(getbnum(brd));
}
+ return ret;
}
static void
@@ -3166,7 +3171,7 @@ static int
del_post(int ent, fileheader_t * fhdr, char *direct)
{
char genbuf[100], newpath[PATHLEN];
- int not_owned, tusernum;
+ int not_owned, tusernum, del_ok = 0;
boardheader_t *bp;
assert(0<=currbid-1 && currbid-1<MAX_BOARD);
@@ -3211,13 +3216,13 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
!delete_record(direct, sizeof(fileheader_t), ent)
) {
- cancelpost(fhdr, not_owned, newpath);
+ del_ok = (cancelpost(fhdr, not_owned, newpath) == 0) ? 1 : 0;
deleteCrossPost(fhdr, bp->brdname);
#ifdef ASSESS
#define SIZE sizeof(badpost_reason) / sizeof(char *)
// TODO not_owned 時也要改變 numpost?
- if (not_owned && tusernum > 0 && !(currmode & MODE_DIGEST)) {
+ if (del_ok && not_owned && tusernum > 0 && !(currmode & MODE_DIGEST)) {
if (now - atoi(fhdr->filename + 2) > 7 * 24 * 60 * 60)
/* post older than a week */
genbuf[0] = 'n';