summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-11-05 22:18:47 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-11-05 22:18:47 +0800
commite125307a579e6bedbf2e184ce970820aeff3c93f (patch)
treeda2769dde698333edf01e77a1e89fd3e6c2cc198 /util
parentad9cd4de1497f3e7fae75d66789c2df16ccef690 (diff)
downloadpttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.tar
pttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.tar.gz
pttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.tar.bz2
pttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.tar.lz
pttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.tar.xz
pttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.tar.zst
pttbbs-e125307a579e6bedbf2e184ce970820aeff3c93f.zip
fix bug of utmpfix fast mode
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@556 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/shmctl.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/util/shmctl.c b/util/shmctl.c
index e658c304..72b7174b 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -1,4 +1,4 @@
-/* $Id: shmctl.c,v 1.28 2002/11/03 15:19:36 in2 Exp $ */
+/* $Id: shmctl.c,v 1.29 2002/11/05 14:18:47 in2 Exp $ */
#include "bbs.h"
extern SHM_t *SHM;
@@ -84,16 +84,15 @@ int utmpfix(int argc, char **argv)
SHM->UTMPbusystate = 1;
printf("starting scaning... %s \n", (fast ? "(fast mode)" : ""));
- if( !fast ){
- time(&now);
- for( i = 0, nactive = 0 ; i < USHM_SIZE ; ++i )
- if( SHM->uinfo[i].pid ){
- idle[nactive].index = i;
- idle[nactive].idle = now - SHM->uinfo[i].lastact;
- ++nactive;
- }
+ time(&now);
+ for( i = 0, nactive = 0 ; i < USHM_SIZE ; ++i )
+ if( SHM->uinfo[i].pid ){
+ idle[nactive].index = i;
+ idle[nactive].idle = now - SHM->uinfo[i].lastact;
+ ++nactive;
+ }
+ if( !fast )
qsort(idle, nactive, sizeof(IDLE_t), sfIDLE);
- }
for( i = 0 ; i < nactive ; ++i ){
which = idle[i].index;
@@ -104,14 +103,14 @@ int utmpfix(int argc, char **argv)
clean = "process error";
purge_utmp(&SHM->uinfo[which]);
}
- else if( !fast ){
- if( searchuser(SHM->uinfo[which].userid) == 0 ){
- clean = "user not exist";
- }
+ else if( searchuser(SHM->uinfo[which].userid) == 0 ){
+ clean = "user not exist";
+ }
#ifdef DOTIMEOUT
- else if( nownum > lowerbound &&
- idle[i].idle >
- (timeout == -1 ? IDLE_TIMEOUT : timeout) ){
+ else if( !fast ){
+ if( nownum > lowerbound &&
+ idle[i].idle >
+ (timeout == -1 ? IDLE_TIMEOUT : timeout) ){
sprintf(buf, "timeout(%s",
ctime(&SHM->uinfo[which].lastact));
buf[strlen(buf) - 1] = 0;
@@ -122,8 +121,8 @@ int utmpfix(int argc, char **argv)
--nownum;
continue;
}
-#endif
}
+#endif
if( clean ){
printf("clean %06d(%s), userid: %s\n",