From 3b64a185e87fdfd39db71bca063b6efb0c7ec92e Mon Sep 17 00:00:00 2001 From: kcwu Date: Fri, 25 Feb 2005 20:14:25 +0000 Subject: * use fnv hash function for all hash. * add version field in SHM. * clean up & reorder SHM, add gaps between arrays. * enlarge USHM_SIZE. * remove unused shmsweep.c. * WARNING, you need to stop bbs and clean old shm before run this revision. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2549 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/cal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'mbbsd/cal.c') diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 1c997836..d0fb17b3 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -3,18 +3,21 @@ /* ¨¾°ô Multi play */ static int -count_multiplay(int unmode) +is_playing(int unmode) { register int i, j; register userinfo_t *uentp; + unsigned int p = StringHash(cuser.userid) % USHM_SIZE; for (i = j = 0; i < USHM_SIZE; i++) { // XXX linear search - uentp = &(SHM->uinfo[i]); + if (p == USHM_SIZE) + p = 0; + uentp = &(SHM->uinfo[p]); if (uentp->uid == usernum) if (uentp->lockmode == unmode) - j++; + return 1; } - return j; + return 0; } int @@ -24,7 +27,7 @@ lockutmpmode(int unmode, int state) if (currutmp->lockmode) errorno = 1; - else if (count_multiplay(unmode)) + else if (is_playing(unmode)) errorno = 2; if (errorno && !(state == LOCK_THIS && errorno == LOCK_MULTI)) { -- cgit v1.2.3