summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-28 23:35:54 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-28 23:35:54 +0800
commit75ce618731831b235e3f6b8e2298e96c73d89da2 (patch)
tree7fe9c64009614f3640ef7c045365badd8cd5f70a /mbbsd
parent11d1c7126baec1ae053f6a4bf5fdac8646e50520 (diff)
downloadpttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.tar
pttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.tar.gz
pttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.tar.bz2
pttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.tar.lz
pttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.tar.xz
pttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.tar.zst
pttbbs-75ce618731831b235e3f6b8e2298e96c73d89da2.zip
uhash problem
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2440 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/cache.c25
-rw-r--r--mbbsd/register.c4
2 files changed, 5 insertions, 24 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index f4996ffb..fee5d950 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -219,35 +219,16 @@ void
setuserid(int num, char *userid)
{
if (num > 0 && num <= MAX_USERS) {
+/* Ptt: it may cause problems
if (num > SHM->number)
SHM->number = num;
else
- remove_from_uhash(num - 1);
+*/
+ remove_from_uhash(num - 1);
add_to_uhash(num - 1, userid);
}
}
-/* 0 ==> 找過期帳號 */
-/* 1 ==> 建立新帳號 */
-/* should do it by searching "" in the hash */
-int
-searchnewuser(int mode)
-{
- register int i, num;
-
- num = SHM->number;
- i = 0;
-
- /* 為什麼這邊不用 hash table 去找而要用 linear search? */
- while (i < num) {
- if (!SHM->userid[i++][0])
- return i;
- }
- if (mode && (num < MAX_USERS))
- return num + 1;
- return 0;
-}
-
#ifndef _BBS_UTIL_C_
char *
u_namearray(char buf[][IDLEN + 1], int *pnum, char *tag)
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 6a2ae01e..67187b0d 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -147,7 +147,7 @@ getnewuserid()
clock = now;
/* Lazy method : 先找尋已經清除的過期帳號 */
- if ((i = searchnewuser(0)) == 0) {
+ if ((i = searchuser("")) == 0) {
/* 每 1 個小時,清理 user 帳號一次 */
if ((stat(fn_fresh, &st) == -1) || (st.st_mtime < clock - 3600)) {
if ((fd = open(fn_fresh, O_RDWR | O_CREAT, 0600)) == -1)
@@ -169,7 +169,7 @@ getnewuserid()
}
}
passwd_lock();
- i = searchnewuser(1);
+ i = searchuser("");
if ((i <= 0) || (i > MAX_USERS)) {
passwd_unlock();
vmsg("抱歉,使用者帳號已經滿了,無法註冊新的帳號");