diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-02-11 01:41:45 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-02-11 01:41:45 +0800 |
commit | 21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db (patch) | |
tree | 028cfb28e049768434832fd6c9301278be03cdab /util | |
parent | 60e0f10f5a60bac35a3de3697e957319e7b5ddc1 (diff) | |
download | pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.tar pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.tar.gz pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.tar.bz2 pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.tar.lz pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.tar.xz pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.tar.zst pttbbs-21ff1ecf3d29680e3d26113eb7caf9f55f0ba5db.zip |
lazy sort utmp
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@653 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r-- | util/shmctl.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/util/shmctl.c b/util/shmctl.c index 1eea2825..f1b7765c 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -1,4 +1,4 @@ -/* $Id: shmctl.c,v 1.31 2003/01/24 19:48:29 in2 Exp $ */ +/* $Id: shmctl.c,v 1.32 2003/02/10 17:41:45 in2 Exp $ */ #include "bbs.h" #include <sys/wait.h> @@ -59,6 +59,7 @@ int utmpfix(int argc, char **argv) time_t now, timeout = -1; char *clean, buf[1024], ch; IDLE_t idle[USHM_SIZE]; + char changeflag = 0; while( (ch = getopt(argc, argv, "nt:l:")) != -1 ) switch( ch ){ @@ -131,9 +132,12 @@ int utmpfix(int argc, char **argv) i, clean, SHM->uinfo[which].userid); memset(&SHM->uinfo[which], 0, sizeof(userinfo_t)); --nownum; + changeflag = 1; } } SHM->UTMPbusystate = 0; + if( changeflag ) + SHM->UTMPneedsort = 1; return 0; } /* end of utmpfix ---------------------------------------------------------- */ @@ -202,6 +206,7 @@ inline void utmpsort(void) userinfo_t *uentp; int count, i, ns; short nusers[MAX_BOARD]; + SHM->UTMPbusystate = 1; SHM->UTMPuptime = time(NULL); ns = (SHM->currsorted ? 0 : 1); @@ -264,7 +269,13 @@ int utmpsortd(int argc, char **argv) } else{ while( 1 ){ - utmpsort(); + int i; + for( i = 0 ; SHM->UTMPbusystate && i < 5 ; ++i ) + usleep(300000); + + if( SHM->UTMPneedsort ) + utmpsort(); + sleep(1); } } |