diff options
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], |