diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-27 10:51:22 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-27 10:51:22 +0800 |
commit | 61eaeca075313705fae418152deae1fef23298d1 (patch) | |
tree | 931689b8528d3efeab94b3c648cff363e147018a | |
parent | a3906f91f849bd46d75725e6e981ff0fe00712d1 (diff) | |
download | pttbbs-61eaeca075313705fae418152deae1fef23298d1.tar pttbbs-61eaeca075313705fae418152deae1fef23298d1.tar.gz pttbbs-61eaeca075313705fae418152deae1fef23298d1.tar.bz2 pttbbs-61eaeca075313705fae418152deae1fef23298d1.tar.lz pttbbs-61eaeca075313705fae418152deae1fef23298d1.tar.xz pttbbs-61eaeca075313705fae418152deae1fef23298d1.tar.zst pttbbs-61eaeca075313705fae418152deae1fef23298d1.zip |
* solve: 'ctrl-u a' several times will drop connection
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4884 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 4 | ||||
-rw-r--r-- | mbbsd/friend.c | 6 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 2 | ||||
-rw-r--r-- | mbbsd/talk.c | 20 |
4 files changed, 21 insertions, 11 deletions
diff --git a/include/proto.h b/include/proto.h index 793fc8b9..3c2895a2 100644 --- a/include/proto.h +++ b/include/proto.h @@ -236,7 +236,7 @@ void reginit_fav(void); /* friend */ void friend_edit(int type); -void friend_load(int); +void friend_load(int type, int do_login); int t_override(void); int t_reject(void); int t_fix_aloha(); @@ -579,7 +579,7 @@ int t_talk(void); int t_display(void); int my_query(const char *uident); int logout_friend_online(userinfo_t*); -void login_friend_online(void); +void login_friend_online(int do_login); int isvisible_uid(int tuid); int friend_stat(const userinfo_t *me, const userinfo_t * ui); int call_in(const userinfo_t *uentp, int fri_stat); diff --git a/mbbsd/friend.c b/mbbsd/friend.c index f3f88925..b19581ad 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -413,7 +413,7 @@ static inline void friend_load_real(int tosort, int maxf, } /* type == 0 : load all */ -void friend_load(int type) +void friend_load(int type, int do_login) { if (!type || type & FRIEND_OVERRIDE) friend_load_real(1, MAX_FRIEND, &currutmp->nFriends, @@ -425,7 +425,7 @@ void friend_load(int type) if (currutmp->friendtotal) logout_friend_online(currutmp); - login_friend_online(); + login_friend_online(do_login); } static void @@ -611,7 +611,7 @@ friend_edit(int type) substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); // log_usies("SetBoard", bp->brdname); } - friend_load(0); + friend_load(0, 0); } } diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 6f436180..a9687ed2 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1078,7 +1078,7 @@ setup_utmp(int mode) /* Very, very slow friend_load. */ if( strcmp(cuser.userid, STR_GUEST) != 0 ) // guest 不處理好友 - friend_load(0); + friend_load(0, 1); nice(3); } diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 28284f28..16be0d89 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -244,7 +244,7 @@ reverse_friend_stat(int stat) } #ifdef UTMPD -int sync_outta_server(int sfd) +int sync_outta_server(int sfd, int do_login) { int i; int offset = (int)(currutmp - &SHM->uinfo[0]); @@ -266,6 +266,16 @@ int sync_outta_server(int sfd) if(res<0) return -1; + + // when we are not doing real login (ex, ctrl-u a or ctrl-u d) + // the frequency check should be avoided. + if (!do_login) + { + sleep(3); // utmpserver usually treat 3 seconds as flooding. + if (res == 2 || res == 1) + res = 0; + } + if(res==2) { close(sfd); outs("登入太頻繁, 為避免系統負荷過重, 請稍後再試\n"); @@ -305,7 +315,7 @@ int sync_outta_server(int sfd) } #endif -void login_friend_online(void) +void login_friend_online(int do_login) { userinfo_t *uentp; int i; @@ -321,7 +331,7 @@ void login_friend_online(void) sfd = toconnect(UTMPD_ADDR); if(sfd>=0) { - int res=sync_outta_server(sfd); + int res=sync_outta_server(sfd, do_login); if(res==0) // sfd will be closed if return 0 return; close(sfd); @@ -2905,7 +2915,7 @@ userlist(void) if (HasUserPerm(PERM_LOGINOK) && !(fri_stat & IFH)) { if (vans("確定要加入好友嗎 [N/y]") == 'y') { friend_add(uentp->userid, FRIEND_OVERRIDE,uentp->nickname); - friend_load(FRIEND_OVERRIDE); + friend_load(FRIEND_OVERRIDE, 0); } redrawall = redraw = 1; } @@ -2915,7 +2925,7 @@ userlist(void) if (HasUserPerm(PERM_LOGINOK) && (fri_stat & IFH)) { if (vans("確定要刪除好友嗎 [N/y]") == 'y') { friend_delete(uentp->userid, FRIEND_OVERRIDE); - friend_load(FRIEND_OVERRIDE); + friend_load(FRIEND_OVERRIDE, 0); } redrawall = redraw = 1; } |