summaryrefslogtreecommitdiffstats
path: root/util/shmctl.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-10 21:18:07 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-10 21:18:07 +0800
commitb9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5 (patch)
treee8272b4de36a873e61c40473f3b7c7a077b0500d /util/shmctl.c
parentf63fd767f682e9eb4d5a2ca37c5884e4a5441b12 (diff)
downloadpttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.tar
pttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.tar.gz
pttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.tar.bz2
pttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.tar.lz
pttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.tar.xz
pttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.tar.zst
pttbbs-b9d50d84ccc8c070c7e38f2a9dcd1f3bb5641df5.zip
HOTBOARDCACHE
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1584 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/shmctl.c')
-rw-r--r--util/shmctl.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/util/shmctl.c b/util/shmctl.c
index 001fd4eb..8b30c758 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -210,6 +210,8 @@ inline void utmpsort(int sortall)
userinfo_t *uentp;
int count, i, ns;
short nusers[MAX_BOARD];
+ boardheader_t *HBcache[HOTBOARDCACHE];
+
SHM->UTMPbusystate = 1;
#ifdef OUTTA_TIMER
@@ -260,9 +262,35 @@ inline void utmpsort(int sortall)
0 < uentp->brc_id && uentp->brc_id < MAX_BOARD)
++nusers[uentp->brc_id - 1];
}
- for (i = 0; i < SHM->Bnumber; ++i)
- if (SHM->bcache[i].brdname[0] != 0)
- SHM->bcache[i].nuser = nusers[i];
+ {
+#if HOTBOARDCACHE
+ int k, r, last = 0, top = 0;
+#endif
+ for (i = 0; i < SHM->Bnumber; ++i)
+ if (SHM->bcache[i].brdname[0] != 0){
+ SHM->bcache[i].nuser = nusers[i];
+#if HOTBOARDCACHE
+ if( nusers[i] > 8 &&
+ (top < HOTBOARDCACHE || nusers[i] > last) &&
+ IS_BOARD(&SHM->bcache[i]) &&
+ IS_OPENBRD(&SHM->bcache[i]) ){
+ for( k = top - 1 ; k >= 0 ; --k )
+ if( nusers[i] < HBcache[k]->nuser )
+ break;
+ if( top < HOTBOARDCACHE )
+ ++top;
+ for( r = top - 1 ; r > (k + 1) ; --r )
+ HBcache[r] = HBcache[r - 1];
+ HBcache[k + 1] = &SHM->bcache[i];
+ last = nusers[(HBcache[top - 1] - SHM->bcache)];
+ }
+#endif
+ }
+#if HOTBOARDCACHE
+ memcpy(SHM->HBcache, HBcache, sizeof(HBcache));
+ SHM->nHOTs = top;
+#endif
+ }
}
SHM->currsorted = ns;