diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-09-20 00:34:04 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-09-20 00:34:04 +0800 |
commit | a38c90eef0f81ccf4b3ab3126969968eb0e8d42d (patch) | |
tree | ad4e55ee824de802959552422e943c0c327af7f1 | |
parent | cd18856cc0cef32fda2c14783125c5773c2ba6e1 (diff) | |
download | pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.tar pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.tar.gz pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.tar.bz2 pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.tar.lz pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.tar.xz pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.tar.zst pttbbs-a38c90eef0f81ccf4b3ab3126969968eb0e8d42d.zip |
* fix crash bug: race condition between idle and talk interrupt.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3558 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/talk.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/mbbsd/talk.c b/mbbsd/talk.c index e2a5ba30..ed2156cb 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -2994,6 +2994,9 @@ t_idle(void) int stat0 = currstat; char genbuf[20]; char passbuf[PASSLEN]; + int idle_type; + char idle_reason[sizeof(currutmp->chatid)]; + setutmpmode(IDLE); getdata(b_lines - 1, 0, "理由:[0]發呆 (1)接電話 (2)覓食 (3)打瞌睡 " @@ -3003,25 +3006,23 @@ t_idle(void) currstat = stat0; return 0; } else if (genbuf[0] >= '1' && genbuf[0] <= '6') - currutmp->destuid = genbuf[0] - '0'; + idle_type = genbuf[0] - '0'; else - currutmp->destuid = 0; + idle_type = 0; - if (currutmp->destuid == 6) - if (!cuser.userlevel || - !getdata(b_lines - 1, 0, "發呆的理由:", - currutmp->chatid, sizeof(currutmp->chatid), DOECHO)) - currutmp->destuid = 0; + if (idle_type == 6) { + if (cuser.userlevel && getdata(b_lines - 1, 0, "發呆的理由:", idle_reason, sizeof(idle_reason), DOECHO)) { + strlcpy(currutmp->chatid, idle_reason, sizeof(currutmp->chatid)); + } else { + idle_type = 0; + } + } + currutmp->destuid = idle_type; do { - /* FIXME destuid 同時表示發呆原因及 talk uid, - * 1. 發呆 - * 2. 有人 talkrequest, 改到 currutmp->destuid - * 3. 打錯密碼 - * 4. 重新顯示 IdleTypeTable[currutmp->destuid], crash */ move(b_lines - 2, 0); clrtoeol(); - prints("(鎖定螢幕)發呆原因: %s", (currutmp->destuid != 6) ? - IdleTypeTable[currutmp->destuid] : currutmp->chatid); + prints("(鎖定螢幕)發呆原因: %s", (idle_type != 6) ? + IdleTypeTable[idle_type] : idle_reason); refresh(); getdata(b_lines - 1, 0, MSG_PASSWD, passbuf, sizeof(passbuf), NOECHO); passbuf[8] = '\0'; |