作者lihgong (Q.Q)
看板PttCurrent
标题[问题] 没办法增加我的最爱使用者
时间Sat Aug 21 22:54:57 2004
我的站上出现一点问题
我把追踪的结果post出来
希望站大有空帮我的忙 (这可能是个bug)
问题是这样子
我站上所有使用者
没办法加入一个id为好友 (id是 zoo)
在使用者名单增加好友以後
该个id不会变色
我检查了 overrides
确定该笔 id 有进入档案
然後我在程式码里加了一些东西
检查 SHM->uinfo->friend
SHM->uinfo->friend_online
确定 zoo 的资料有读入而且正确
我比对了一些地方
最後trace到 talk.c, pickup_myfriend()
pickup_myfriend(pickup_t * friends,
int *myfriend, int *friendme, int *badfriend)
{
userinfo_t *uentp;
int i, where, frstate, ngets = 0;
*badfriend = 0;
*myfriend = *friendme = 1;
for (i = 0; currutmp->friend_online[i] && i < MAX_FRIEND; ++i) {
where = currutmp->friend_online[i] & 0xFFFFFF;
/* Begin of DEBUG code */
uentp = &SHM->uinfo[where];
vmsg("%s", uentp->userid);
vmsg("%d", where);
if(0 <= where) vmsg("ck1");
if(where < MAX_ACTIVE) vmsg("ck2");
if(uentp = &SHM->uinfo[where]) vmsg("ck3");
if(uentp->pid) vmsg("ck4");
/* End of DEBUG code */
if (0 <= where && where < MAX_ACTIVE &&
红色的程式码, 会取出zoo这个id在 uinfo[] 阵列的 index, 存在 where
绿色的程式码, 会检查 where 是否超出范围
检查的结果, zoo这个id每次都会超出 MAX_ACTIVE
------
我怀疑是上站时
配置uinfo位置程式码有问题
我找到了 cache.c, getnewutmpent()
void
getnewutmpent(userinfo_t * up)
{
/* Ptt:这里加上 hash 观念找空的 utmp */
register int i, p;
register userinfo_t *uentp;
for (i = 0, p = StringHash(up->userid) % USHM_SIZE; i < USHM_SIZE; i++, p++) {
if (p == USHM_SIZE)
p = 0;
// vmsg("utmp location: %d", p);
uentp = &(SHM->uinfo[p]);
if (!(uentp->pid)) {
memcpy(uentp, up, sizeof(userinfo_t));
currutmp = uentp;
return;
}
}
我站上的 MAX_ACTIVE 设成 1024
当 zoo 这个 id 送入 StringHash()
传回值就是 1024
所以每次 zoo 上站时
他永远被配置在 uinfo[1024] / uinfo[1025] / info[1026] / info[1027]
导致前面检查 where < MAX_ACTIVE 永远出错
上面标黄色的程式码改成
if(p >= MAX_ACTIVE)
可以治标
只是USHM_SIZE为什麽要设成MAX_ACTIVE + 4
在这边造成一些不一致的问题
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.168.153.227