荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: Lg (创造人生的传奇), 信区: InstallBBS
标 题: [转载] Re: 也救救我们的BBS(转寄)
发信站: BBS 荔园晨风站 (Mon Jul 5 20:21:17 1999), 站内信件
【 以下文字转载自 Lg 的信箱 】
【 原文由 liugang.bbs@bbs.net.tsinghua.edu.cn 所发表 】
发信人: fuse (保险丝), 信区: BBSMan_Dev
标 题: Re: 也救救我们的BBS
发信站: BBS 水木清华站 (Thu Jun 17 03:20:05 1999)
【 在 zhbing (快乐小兵) 的大作中提到: 】
: 是的,难道FreeBSD没有这个问题?
对,不会有这样的问题了
关于留言板挂住,贴一篇文章,供各位参考:
作者: Ptt (杜奕瑾) 看板: Administor
标题: 可能找到到十大热们话题会停住的bug
时间: Tue Nov 4 04:08:19 1997
现在已知道
托垮整个bbs的速度不是PASSWD档爆掉
是主选单的动态看板
do {
if (!i)
i = (rand() % ptt->max_film) + 1;
for (now = ptt->max_history; now >= 0; now--)
if (i == history[now]) {
i = 0;
break;
}
} while (i == 0);
这一段..
如果刚好share memory在update时出错 ptt->max_history 变成 负的或是很大
这一段就成了forever loop 所有的bbsprocess就都变成 while(1)的程式
此段code在十大热门话题後会执行 所以就大家都login到时大热门话题就停了
防止方法
menu.c改成
+ else if(!ptt->busystate) /* race condition */
+ {
do {
if (!i)
i = (rand() % ptt->max_film) + 1;
for (now = ptt->max_history; now >= 0; now--)
if (i == history[now]) {
i = 0;
break;
}
} while (i == 0);
+ }
+ else
+ {
+ i = 1;
+ }
cache.c改成
reload_pttcache()
{
:
ptt->max_film = id-1;
ptt->max_history = ptt->max_film - 2;
if (ptt->max_history > MAX_HISTORY - 1)
ptt->max_history = MAX_HISTORY - 1;
+ if (ptt->max_history <0) ptt->max_history=0;
:
}
参考文件--------------------------------------------------------------
reference:
作者: rexchen (小旭旭)
标题: menu.c
时间: Sun Sep 21 03:35:01 1997
do {
if (!i)
i = (rand() % max_film) + 1;
for (now = max_history; now >= 0; now--)
if (i == history[now]) {
i = 0;
break;
}
} while (i == 0);
这里好像会陷入无限回圈
我 mark 掉後就没事了。
※ 发信站: 批踢踢实业坊(ptt.m8.ntu.edu.tw)
◆ From: pttchief.m8.ntu
> -------------------------------------------------------------------------- <
作者: Ptt (杜奕瑾) 看板: PttSrc
标题: Re: 可能找到到十大热们话题会停住的bug
时间: Wed Nov 5 23:37:02 1997
※ 引述《Ptt (杜奕瑾)》之铭言:
: 现在已知道
: 托垮整个bbs的速度不是PASSWD档爆掉
: 是主选单的动态看板
: do {
: if (!i)
: i = (rand() % ptt->max_film) + 1;
: for (now = ptt->max_history; now >= 0; now--)
: if (i == history[now]) {
: i = 0;
: break;
: }
: } while (i == 0);
: 这一段..
: 如果刚好share memory在update时出错 ptt->max_history 变成 负的或是很大
: 这一段就成了forever loop 所有的bbsprocess就都变成 while(1)的程式
: 此段code在十大热门话题後会执行 所以就大家都login到时大热门话题就停了
: 防止方法
: menu.c改成
: + else if(!ptt->busystate) /* race condition */
: + {
: do {
: if (!i)
: i = (rand() % ptt->max_film) + 1;
~~~~~~~~~~~~~~~~~~~~~~
这边原本写法有问题
改成降吧..
i = 1+(int) (ptt->max_film * rand()/(RAND_MAX+1.0));
我man rand说的...........
In Numerical Recipes in C: The Art of Scientific Computing
(William H. Press, Brian P. Flannery, Saul A. Teukolsky,
William T. Vetterling; New York: Cambridge University
Press, 1990 (1st ed, p. 207)), the following comments are
made:
"If you want to generate a random integer between 1
and 10, you should always do it by
j=1+(int) (10.0*rand()/(RAND_MAX+1.0));
and never by anything resembling
j=1+((int) (1000000.0*rand()) % 10);
(which uses lower-order bits)."
Random-number generation is a complex topic. The Numeri-
cal Recipes in C book (see reference above) provides an
excellent discussion of practical random-number generation
issues in Chapter 7 (Random Numbers).
--
※ 发信站: 批踢踢实业坊(ptt.m8.ntu.edu.tw)
◆ From: pttchief.m8.ntu
--
hope helpful.
--
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 210.32.151.168]
--
※ 转载:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: 210.39.3.82]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店