diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-04-10 04:29:38 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-04-10 04:29:38 +0800 |
commit | 44aafbbb3e463ec686d1bac7b3f0707d905d010e (patch) | |
tree | bdcc643f4206c0cf3241e59f8f258479c791a8d6 /util/shmctl.c | |
parent | 2be2268af61905f408f33f2a4d439829ca23a0be (diff) | |
download | pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.tar pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.tar.gz pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.tar.bz2 pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.tar.lz pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.tar.xz pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.tar.zst pttbbs-44aafbbb3e463ec686d1bac7b3f0707d905d010e.zip |
use logout_friend if timeout
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@94 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/shmctl.c')
-rw-r--r-- | util/shmctl.c | 38 |
1 files 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 <signal.h> #include <sys/types.h> #include <sys/shm.h> +#include <errno.h> #include "config.h" #include "pttstruct.h" #include "util.h" -#include <errno.h> +#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; 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--; + 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], |