From bee171e6635b88aa65c696f4ff2665cddf886e48 Mon Sep 17 00:00:00 2001 From: in2 Date: Tue, 9 Apr 2002 20:10:31 +0000 Subject: remove pickup_t:idle, clean of idle timeout to shmctl git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@92 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/shmctl.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'util/shmctl.c') diff --git a/util/shmctl.c b/util/shmctl.c index 13b97d14..0d8a3589 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include "config.h" #include "pttstruct.h" @@ -17,29 +16,31 @@ extern struct utmpfile_t *utmpshm; int utmpfix(int argc, char **argv) { int i; + time_t now; char buf[1024], *clean; - struct stat st; - if( utmpshm->busystate ){ - puts("utmpshm is busy"); - return 0; - } + + time(&now); + for( i = 0 ; i < 5 ; ++i ) + if( !utmpshm->busystate ) + break; + else{ + puts("utmpshm is busy...."); + sleep(1); + } 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"; else{ - sprintf(buf, "/proc/%d", utmpshm->uinfo[i].pid); - if( stat(buf, &st) < 0 ) - clean = "process not exist"; - else{ - sprintf(buf, "home/%c/%s", - utmpshm->uinfo[i].userid[0], - utmpshm->uinfo[i].userid); - if( stat(buf, &st) < 0 ) - clean = "user not exist"; - } + sprintf(buf, "home/%c/%s", + utmpshm->uinfo[i].userid[0], + utmpshm->uinfo[i].userid); + if( access(buf, 0) < 0 ) + clean = "user not exist"; } if( clean ){ -- cgit v1.2.3