summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-05-15 19:16:33 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-05-15 19:16:33 +0800
commit852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb (patch)
tree252c8376f9c5e25143a65a9ca373f67f4f1b6ac9 /util
parent4968f459b5a47b723b550d9d50a4d17f5031f3e9 (diff)
downloadpttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.tar
pttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.tar.gz
pttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.tar.bz2
pttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.tar.lz
pttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.tar.xz
pttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.tar.zst
pttbbs-852ce36e502ee9b02afb8b6bbb6ca11ebb07b1bb.zip
idle time
use searchuser to search if user exists git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@175 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/shmctl.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/util/shmctl.c b/util/shmctl.c
index d6818344..970919bc 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -23,15 +23,19 @@ int logout_friend_online(userinfo_t *utmp)
while(utmp->friendtotal){
i = utmp->friendtotal-1;
j = (utmp->friend_online[i] & 0xFFFFFF);
- utmp->friend_online[i]=0;
- ui = &utmpshm->uinfo[j];
- if(ui->pid && ui!=utmp){
- for(k=0; k<ui->friendtotal &&
- (int)(ui->friend_online[k] & 0xFFFFFF) !=offset; k++);
- if(k<ui->friendtotal){
- ui->friendtotal--;
- ui->friend_online[k]=ui->friend_online[ui->friendtotal];
- ui->friend_online[ui->friendtotal]=0;
+ if( !(0 <= j && j < MAX_ACTIVE) )
+ printf("\tonline friend error(%d)\n", j);
+ else{
+ utmp->friend_online[i]=0;
+ ui = &utmpshm->uinfo[j];
+ if(ui->pid && ui!=utmp){
+ for(k=0; k<ui->friendtotal &&
+ (int)(ui->friend_online[k] & 0xFFFFFF) !=offset; k++);
+ if(k<ui->friendtotal){
+ ui->friendtotal--;
+ ui->friend_online[k]=ui->friend_online[ui->friendtotal];
+ ui->friend_online[ui->friendtotal]=0;
+ }
}
}
utmp->friendtotal--;
@@ -48,9 +52,12 @@ void purge_utmp(userinfo_t *uentp)
int utmpfix(int argc, char **argv)
{
- int i;
+ int i, fast = 0;
time_t now;
- char buf[1024], *clean;
+ char *clean;
+
+ if( argc >= 1 && strcmp(argv[0], "-n") == 0 )
+ fast = 1;
time(&now);
for( i = 0 ; i < 5 ; ++i )
@@ -60,23 +67,25 @@ int utmpfix(int argc, char **argv)
puts("utmpshm is busy....");
sleep(1);
}
+ printf("starting scaning... %s \n", (fast ? "(fast mode)" : ""));
utmpshm->busystate = 1;
for( i = 0 ; i < USHM_SIZE ; ++i )
if( utmpshm->uinfo[i].pid ){
clean = NULL;
if( !isalpha(utmpshm->uinfo[i].userid[0]) )
clean = "userid error";
- else if( now - utmpshm->uinfo[i].lastact > 1800 ){
- clean = "timeout";
- kill(utmpshm->uinfo[i].pid, SIGHUP);
- purge_utmp(&utmpshm->uinfo[i]);
- }
- else{
- sprintf(buf, "home/%c/%s",
- utmpshm->uinfo[i].userid[0],
- utmpshm->uinfo[i].userid);
- if( access(buf, 0) < 0 )
+ else if( !fast ){
+#ifdef DOTIMEOUT
+ if( now - utmpshm->uinfo[i].lastact > IDLE_TIMEOUT ){
+ clean = "timeout";
+ kill(utmpshm->uinfo[i].pid, SIGHUP);
+ purge_utmp(&utmpshm->uinfo[i]);
+ }
+ else
+#endif
+ if( searchuser(utmpshm->uinfo[i].userid) == 0 ){
clean = "user not exist";
+ }
}
if( clean ){