diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-26 04:14:25 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-26 04:14:25 +0800 |
commit | 3b64a185e87fdfd39db71bca063b6efb0c7ec92e (patch) | |
tree | 8678540a15b6a541d21f176ab46dbeb48d6cdfde /mbbsd/cal.c | |
parent | 58490fa9b998ccd714de75f48a9c1eb5f914995d (diff) | |
download | pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.tar pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.tar.gz pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.tar.bz2 pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.tar.lz pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.tar.xz pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.tar.zst pttbbs-3b64a185e87fdfd39db71bca063b6efb0c7ec92e.zip |
* 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
Diffstat (limited to 'mbbsd/cal.c')
-rw-r--r-- | mbbsd/cal.c | 13 |
1 files changed, 8 insertions, 5 deletions
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)) { |