From 44aafbbb3e463ec686d1bac7b3f0707d905d010e Mon Sep 17 00:00:00 2001 From: in2 Date: Tue, 9 Apr 2002 20:29:38 +0000 Subject: use logout_friend if timeout git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@94 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/shmctl.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/util/shmctl.c b/util/shmctl.c index 0d8a3589..0205681f 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -6,13 +6,45 @@ #include #include #include +#include #include "config.h" #include "pttstruct.h" #include "util.h" -#include +#include "proto.h" extern struct utmpfile_t *utmpshm; +int logout_friend_online(userinfo_t *utmp) +{ + int i, j, k; + int offset=(int) (utmp - &utmpshm->uinfo[0]); + userinfo_t *ui; + 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; kfriendtotal && + (int)(ui->friend_online[k] & 0xFFFFFF) !=offset; k++); + if(kfriendtotal){ + ui->friendtotal--; + ui->friend_online[k]=ui->friend_online[ui->friendtotal]; + ui->friend_online[ui->friendtotal]=0; + } + } + utmp->friendtotal--; + utmp->friend_online[utmp->friendtotal]=0; + } + return 0; +} + +void purge_utmp(userinfo_t *uentp) +{ + logout_friend_online(uentp); + //memset(uentp, 0, sizeof(userinfo_t)); +} + int utmpfix(int argc, char **argv) { int i; @@ -33,8 +65,10 @@ int utmpfix(int argc, char **argv) clean = NULL; if( !isalpha(utmpshm->uinfo[i].userid[0]) ) clean = "userid error"; - else if( now - utmpshm->uinfo[i].lastact > 1800 ) + else if( now - utmpshm->uinfo[i].lastact > 1800 ){ clean = "timeout"; + purge_utmp(&utmpshm->uinfo[i]); + } else{ sprintf(buf, "home/%c/%s", utmpshm->uinfo[i].userid[0], -- cgit v1.2.3