根据 smthbbs 1.2.2 的 doc/userid 文档,fb 代码原本是没有用 hash 来检索
用户id的,而smth的代码采用了自己特制的 hash 来加快检索速度。
ucache 里的代码不太好懂,我看了半天,有两个问题:
1, hash 加快的检索效率到底对 bbs 的运行有没有实质性的帮助?这个我不知道
前辈有没有测试过。会不会实际情况是因为 hash 而提高的效率相对于 io
瓶颈来说对bbs的运行效率并没有什么提高?
2, hash 的一个缺点是查询用户的时候,列出用户是无序的,而且必须先输入两个
字符才能查询,代码本身也很复杂。如果用b-tree给用户索引是不是能够解决
这个麻烦点呢?
3, miscd userd 是添加和删除用户用的吧?为什么要用一个单独的daemon来添加
删除用户,而不是直接通过 libBBS 的函数调用实现呢?
4, libBBS/ucache.c 里的 fillucache 函数里有一句话似乎不对:
if (uidshm->passwd[*number].numlogins > uentp->numlogins) {
// the later entry is `newer' than the former entry.
bbslog("3passwd", "deleted %s in %d", uentp->userid, i - 1);
// delete the former entry from the hash list.
if (prev == -1)
uidshm->hashhead[hashkey] = uidshm->next[i - 1];
else
uidshm->next[prev - 1] = uidshm->next[i - 1];
// clear the content of the existing user entry.
uentp->userid[0] = 0;
uidshm->next[i - 1] = 0;// XXX: 是否应该等于 uidshm->hashhead[0]?
// But this will confuse 10 lines below:
// i = uidshm->next[i-1] ...
uidshm->hashhead[0] = i;
} else {
....
谢谢前辈啦!^^
--
FROM 59.66.199.*