diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-09 00:41:09 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-09 00:41:09 +0800 |
commit | 749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c (patch) | |
tree | d3486e0762c0ac53958851a5500ad54f70d375b3 | |
parent | a56697a4d2dd0507a20c5184d41349a1b07df31c (diff) | |
download | pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.tar pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.tar.gz pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.tar.bz2 pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.tar.lz pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.tar.xz pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.tar.zst pttbbs-749b08d0e4d06e3e6b17f0675d8dae507f5cbf4c.zip |
fix non-big5 typo in r3012
and make locking more solid
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3013 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/bbs.c | 14 | ||||
-rw-r--r-- | mbbsd/gamble.c | 36 | ||||
-rw-r--r-- | mbbsd/stuff.c | 4 |
3 files changed, 35 insertions, 19 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 0bd52e5e..fbe6b7ef 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1566,13 +1566,14 @@ hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) return 0; if (bp->brdattr & BRD_BAD ) { - vmsg("¹Hªk¬Ý¬ÝݪO¸T¤îî¨ÏÏ¥Îνää½L"); + vmsg("¹Hªk¬ÝªO¸T¤î¨Ï¥Î½ä½L"); return 0; } setbfile(fn_ticket, currboard, FN_TICKET); setbfile(fn_ticket_end, currboard, FN_TICKET_END); setbfile(genbuf, currboard, FN_TICKET_LOCK); + if (dashf(fn_ticket)) { getdata(b_lines - 1, 0, "¤w¸g¦³Á|¿ì½ä½L, " "¬O§_n [°±¤î¤Uª`]?(N/y)¡G", yn, 3, LCECHO); @@ -1593,7 +1594,7 @@ hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) return FULLUPDATE; if(cpuload(NULL) > MAX_CPULOAD/4) { - vmsg("t²üü¹L°ªª ½ÐЩóó¨t²ÎÎt²üü§C®Éɶ}¼ú.."); + vmsg("t²ü¹L°ª ½Ð©ó¨t²Ît²ü§C®É¶}¼ú.."); return FULLUPDATE; } openticket(currbid); @@ -1630,7 +1631,8 @@ hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) } move(6, 0); snprintf(genbuf, sizeof(genbuf), - "½Ð¨ì %s ªO «ö'f'°Ñ»P½ä³Õ!\n\n¤@±i %d Ptt¹ô, ³o¬O%sªº½ä³Õ\n%s%s\n", + "\n½Ð¨ì %s ªO «ö'f'°Ñ»P½ä³Õ!\n\n" + "¤@±i %d Ptt¹ô, ³o¬O%sªº½ä³Õ\n%s%s\n", currboard, i, i < 100 ? "¤p½ä¦¡" : i < 500 ? "¥¥Á¯Å" : i < 1000 ? "¶Q±Ú¯Å" : i < 5000 ? "´I»¨¯Å" : "¶É®a¿º²£", @@ -1638,7 +1640,8 @@ hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) bp->endgamble ? Cdate(&bp->endgamble) : "" ); strcat(msg, genbuf); - outs("½Ð¨Ì¦¸¿é¤J±m²¼¦WºÙ, »Ý´£¨Ñ2~8¶µ. (¥¼º¡¤K¶µ, ¿é¤Jª½±µ«öenter)\n"); + outs("½Ð¨Ì¦¸¿é¤J±m²¼¦WºÙ, »Ý´£¨Ñ2~8¶µ. (¥¼º¡¤K¶µ, ¿é¤Jª½±µ«öEnter)\n"); + //outs(ANSI_COLOR(1;33) "ª`·N¿é¤J«áµLªkקï¡I\n"); for( i = 0 ; i < 8 ; ++i ){ snprintf(yn, sizeof(yn), " %d)", i + 1); getdata(7 + i, 0, yn, genbuf, 9, DOECHO); @@ -1653,8 +1656,6 @@ hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) setbfile(genbuf, currboard, FN_TICKET_USER); unlink(genbuf); // Ptt: ¨¾°ô§Q¥Î¤£¦Pid¦P®ÉÁ|¿ì½ä³õ - move(8 + i, 0); - outs("½ä½L³]©w§¹¦¨"); snprintf(genbuf, sizeof(genbuf), "[¤½§i] %s ªO ¶}©l½ä³Õ!", currboard); post_msg(currboard, genbuf, msg, cuser.userid); post_msg("Record", genbuf + 7, msg, "[°¨¸ô±´¤l]"); @@ -1662,6 +1663,7 @@ hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) rename(fn_ticket_end, fn_ticket); /* ³]©w§¹¤~§âÀɦW§ï¹L¨Ó */ + vmsg("½ä½L³]©w§¹¦¨"); return FULLUPDATE; } #endif diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index b66428e2..69c93d6d 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -195,7 +195,7 @@ doesnt_catch_up: price = price * n; if (price > 0) deumoney(currutmp->uid, price); - vmsg("«z!! @£«®º...ªO¥D¤w¸g°±¤î¤Uª`¤F ¤£¯à½äÂP"); + vmsg("ªO¥D¤w¸g°±¤î¤Uª`¤F ¤£¯à½äÂP"); unlockutmpmode(); return -1; } @@ -203,8 +203,9 @@ doesnt_catch_up: int openticket(int bid) { - char path[128], buf[256], outcome[128]; - int i, money = 0, count, bet, price, total = 0, ticket[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + char path[MAXPATHLEN], buf[MAXPATHLEN], outcome[MAXPATHLEN]; + int i, money = 0, count, bet, price, total = 0, + ticket[8] = {0, 0, 0, 0, 0, 0, 0, 0}; boardheader_t *bh = getbcache(bid); FILE *fp, *fp1; char betname[MAX_ITEM][MAX_ITEM_LEN]; @@ -233,12 +234,29 @@ openticket(int bid) getdata(21, 0, ANSI_COLOR(1) "¦A¦¸½T»{¿é¤J¸¹½X" ANSI_RESET ":", buf, 3, LCECHO); } while (bet != atoi(buf)); + // before we fork to process, + // confirm lock status is correct. + setbfile(buf, bh->brdname, FN_TICKET_END); + setbfile(outcome, bh->brdname, FN_TICKET_LOCK); + + if(access(outcome, 0) == 0) + { + unlockutmpmode(); + vmsg("¤w¥t¦³¤H¶}¼ú¡A¨t²Îµy«á±N¦Û°Ê¤½§G¤¤¼úµ²ªG©ó¬ÝªO"); + return 0; + } + if(rename(buf, outcome) != 0) + { + unlockutmpmode(); + vmsg("µLªk·Ç³Æ¶}¼ú... ½Ð¦Ü PttBug ³ø§i¨Ãªþ¤WªO¦W¡C"); + return 0; + + } + if (fork()) { /* Ptt: ¥Î fork() ¨¾¤î¤£¥¿±`Â_½u¬~¿ú */ - move(22, 0); - outs("¨t²Î±N©óµy«á¦Û°Ê§â¤¤¼úµ²ªG¤½§G©ó¬ÝªO Y°Ñ¥[ªÌ¦h·|»Ýn´X¤ÀÄÁ®É¶¡.."); - pressanykey(); unlockutmpmode(); + vmsg("¨t²Îµy«á±N¦Û°Ê¤½§G©ó¤¤¼úµ²ªG¬ÝªO(°Ñ¥[ªÌ¦h®Én¼Æ¤ÀÄÁ).."); return 0; } close(0); @@ -257,7 +275,7 @@ openticket(int bid) bet--; /* Âন¯x°}ªºindex */ total = load_ticket_record(path, ticket); - setbfile(buf, bh->brdname, FN_TICKET_END); + setbfile(buf, bh->brdname, FN_TICKET_LOCK); if (!(fp1 = fopen(buf, "r"))) exit(1); @@ -305,10 +323,6 @@ openticket(int bid) } // XXX somebody may use fp even fp==NULL fclose(fp1); - - setbfile(buf, bh->brdname, FN_TICKET_END); - setbfile(path, bh->brdname, FN_TICKET_LOCK); - rename(buf, path); /* * ¥H¤U¬Oµ¹¿ú°Ê§@ */ diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index 3789f2a8..2ec3ba1c 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -925,7 +925,7 @@ void *MALLOC(int size) MAP_ANON | MAP_PRIVATE, -1, 0); p[0] = size; #if defined(DEBUG) && !defined(_BBS_UTIL_C_) - vmsg("critical malloc %d bytes", size); + vmsgf("critical malloc %d bytes", size); #endif return (void *)&p[1]; } @@ -935,7 +935,7 @@ void FREE(void *ptr) int size = ((int *)ptr)[-1]; munmap((void *)(&(((int *)ptr)[-1])), size); #if defined(DEBUG) && !defined(_BBS_UTIL_C_) - vmsg("critical free %d bytes", size); + vmsgf("critical free %d bytes", size); #endif } #endif |