From e8fc08b9800ba86163e5bf43469cdc9f4b478b13 Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 6 Jun 2002 21:35:23 +0000 Subject: only one shared memory git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@296 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/board.c | 70 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'mbbsd/board.c') diff --git a/mbbsd/board.c b/mbbsd/board.c index 15cdee5b..ad19d881 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1,4 +1,4 @@ -/* $Id: board.c,v 1.34 2002/06/05 03:10:43 ptt Exp $ */ +/* $Id: board.c,v 1.35 2002/06/06 21:34:11 in2 Exp $ */ #include "bbs.h" #define BRC_STRLEN 15 /* Length of board name */ #define BRC_MAXSIZE 24576 @@ -354,23 +354,21 @@ static void load_uidofgid(const int gid, const int type){ boardheader_t *bptr,*currbptr; int n, childcount=0; currbptr = &bcache[gid-1]; - for(n=0;nsorted[type][n]; - if(bptr->brdname[0]=='\0') continue; - if(bptr->gid == gid) - { - if(currbptr == &bcache[gid-1]) - currbptr->firstchild[type]=bptr; - else - { - currbptr->next[type]=bptr; - currbptr->parent=&bcache[gid-1]; + for( n = 0 ; n < numboards ; ++n ){ + bptr = SHM->bsorted[type][n]; + if( bptr->brdname[0] == '\0' ) + continue; + if( bptr->gid == gid ){ + if(currbptr == &bcache[gid-1]) + currbptr->firstchild[type]=bptr; + else{ + currbptr->next[type]=bptr; + currbptr->parent=&bcache[gid-1]; } - childcount++; - currbptr=bptr; - } - } + childcount++; + currbptr=bptr; + } + } bcache[gid-1].childcount=childcount; if(currbptr == &bcache[gid-1]) currbptr->firstchild[type]=(boardheader_t *) ~0; @@ -381,8 +379,8 @@ static boardstat_t * addnewbrdstat(int n, int state) { boardstat_t *ptr=&nbrd[brdnum++]; boardheader_t *bptr = &bcache[n]; - ptr->total = &(brdshm->total[n]); - ptr->lastposttime = &(brdshm->lastposttime[n]); + ptr->total = &(SHM->total[n]); + ptr->lastposttime = &(SHM->lastposttime[n]); ptr->bid = n+1; ptr->myattr=0; ptr->myattr=(favbuf[n]&~BRD_ZAP); @@ -418,7 +416,7 @@ static void load_boards(char *key) { nbrd = (boardstat_t *)malloc(numboards * sizeof(boardstat_t)); for(i=0 ; i < numboards; i++) { - if( (bptr = brdshm->sorted[type][i]) == NULL ) + if( (bptr = SHM->bsorted[type][i]) == NULL ) continue; n = (int)( bptr - bcache); if(!bptr->brdname[0] || bptr->brdattr & BRD_GROUPBOARD || @@ -656,21 +654,23 @@ static void dozap(int num){ void delutmpbid(int bid, userinfo_t *utmp) { userinfo_t *u; - while (brdshm->busystate || now-brdshm->busystate_b[bid-1]<5) - sleep(1); - // Ptt:有問題都是這邊沒有執行到就爛掉了 - - brdshm->busystate_b[bid-1]=now; - u=bcache[bid-1].u; - if(u!=(void*)utmp) - { - for(;u && u->nextbfriend != (void*)utmp; u=u->nextbfriend); - if(u) u->nextbfriend = utmp->nextbfriend; - } - else - bcache[bid-1].u=utmp->nextbfriend; - if(bcache[bid-1].nuser>0) bcache[bid-1].nuser--; - brdshm->busystate_b[bid-1]=0; + while( SHM->Bbusystate || now - SHM->busystate_b[bid - 1] < 5 ) + sleep(1); + // Ptt:有問題都是這邊沒有執行到就爛掉了 + + SHM->busystate_b[bid-1] = now; + u = bcache[bid - 1].u; + if( u != (void *)utmp ){ + for( ; u && u->nextbfriend != (void*)utmp; u = u->nextbfriend ) + ; + if( u ) + u->nextbfriend = utmp->nextbfriend; + } + else + bcache[bid - 1].u = utmp->nextbfriend; + if( bcache[bid - 1].nuser > 0 ) + bcache[bid - 1].nuser--; + SHM->busystate_b[bid - 1] = 0; } void setutmpbid(int bid) -- cgit v1.2.3