summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cacheserver/utmpserver.c2
-rw-r--r--mbbsd/talk.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/cacheserver/utmpserver.c b/cacheserver/utmpserver.c
index 592cd7d0..82832b8f 100644
--- a/cacheserver/utmpserver.c
+++ b/cacheserver/utmpserver.c
@@ -117,6 +117,8 @@ int main(int argc, char **argv)
if( toread(cfd, &uid, sizeof(uid)) > 0 &&
toread(cfd, utmp[index].friend, sizeof(utmp[index].friend)) > 0 &&
toread(cfd, utmp[index].reject, sizeof(utmp[index].reject)) > 0 ){
+ /* 因為 logout 的時候並不會通知 utmpserver , 可能會查到一些
+ 已經 logout 的帳號。所以不能只取 MAX_FRIEND 而要多取一些 */
#define MAX_FS (2 * MAX_FRIEND)
int iu, nFrs, stat, rstat;
ocfs_t fs[MAX_FS];
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index f8799f4e..8765fe40 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -230,12 +230,18 @@ void login_friend_online(void)
towrite(sfd, currutmp->friend, sizeof(currutmp->friend)) > 0 &&
towrite(sfd, currutmp->reject, sizeof(currutmp->reject)) > 0 ){
ocfs_t fs;
- while( toread(sfd, &fs, sizeof(fs)) > 0 )
+ while( currutmp->friendtotal < MAX_FRIEND &&
+ toread(sfd, &fs, sizeof(fs)) > 0 )
if( SHM->uinfo[fs.index].uid == fs.uid ){
currutmp->friend_online[currutmp->friendtotal++]
= fs.friendstat;
SHM->uinfo[fs.index].friend_online[ SHM->uinfo[fs.index].friendtotal++ ] = fs.rfriendstat;
}
+
+ /* 要把剩下的收完, 要不然會卡死 utmpserver */
+ if( currutmp->friendtotal == MAX_FRIEND )
+ while( toread(sfd, &fs, sizeof(fs)) > 0 )
+ ;
close(sfd);
return;
}