diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-04-10 04:10:31 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-04-10 04:10:31 +0800 |
commit | bee171e6635b88aa65c696f4ff2665cddf886e48 (patch) | |
tree | a44eb6738c799bc4ec392c0f10f004374ca8a34a | |
parent | 1334ecd6b1bc494e0ddc18055b650d1f31334842 (diff) | |
download | pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.gz pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.bz2 pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.lz pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.xz pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.zst pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.zip |
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
-rw-r--r-- | mbbsd/talk.c | 14 | ||||
-rw-r--r-- | util/shmctl.c | 33 |
2 files changed, 26 insertions, 21 deletions
diff --git a/mbbsd/talk.c b/mbbsd/talk.c index c9b108c8..d2c6fb8a 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.18 2002/03/20 13:49:45 ptt Exp $ */ +/* $Id: talk.c,v 1.19 2002/04/09 20:10:31 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <errno.h> @@ -69,7 +69,7 @@ typedef struct talkwin_t { typedef struct pickup_t { userinfo_t *ui; - time_t idle; + //time_t idle; int friend; } pickup_t; @@ -1525,7 +1525,7 @@ static int pickup_user_cmp(time_t now, int sortedway, int cmp_fri, pickup_t pklist[], int *bfriends_number, int *ifh_number, int *hfm_number,int *irh_number, char *keyword) { - int i, fri_stat, is_friend, count=0, diff; + int i, fri_stat, is_friend, count=0; userinfo_t *uentp; for (i=0;i<utmpshm->number;i++){ uentp = (utmpshm->sorted[utmpshm->currsorted][sortedway][i]); @@ -1544,10 +1544,12 @@ static int pickup_user_cmp(time_t now, int sortedway, int cmp_fri, if (ifh_number && fri_stat & IFH) (*ifh_number)++; if (hfm_number && fri_stat & HFM) (*hfm_number)++; if (irh_number && fri_stat & IRH) (*irh_number)++; +#if 0 #ifdef SHOW_IDLE_TIME diff = now - uentp->lastact; #ifdef DOTIMEOUT - /* prevent fault /dev mount from kicking out users */ + /* in2: timeout拿到 shmctl utmpfix去做, 一小時一次就夠了 */ + /* prevent fault /dev mount from kicking out users */ if ((diff > curr_idle_timeout + 10) && (diff < 60 * 60 * 24 * 5)){ if ((uentp->pid <= 0 || kill(uentp->pid, SIGHUP) == -1) && @@ -1558,6 +1560,7 @@ static int pickup_user_cmp(time_t now, int sortedway, int cmp_fri, #endif pklist[count].idle = diff; #endif +#endif pklist[count].friend = fri_stat; pklist[count].ui = uentp; count++; @@ -1721,7 +1724,8 @@ static void pickup_user(void) continue; } #ifdef SHOW_IDLE_TIME - diff = pklist[ch].idle; + diff = freshtime - pklist[ch].ui->lastact; + //diff = pklist[ch].idle; if (diff > 59990) diff = 59990; /* Doma: 以免一大串的發呆時間 */ if (diff > 0) sprintf(buf, "%3ld'%02ld", diff / 60, diff % 60); 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 <ctype.h> #include <signal.h> #include <sys/types.h> -#include <sys/stat.h> #include <sys/shm.h> #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 ){ |