From a9194a80af61158ad520eaf2260a739d9e7a368f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 24 Sep 2019 19:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=95=E6=9C=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/wsproxy/constant.h | 1 - server/wsproxy/mastersvrmgr.cc | 24 +++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/server/wsproxy/constant.h b/server/wsproxy/constant.h index 9466d48..a1ab429 100644 --- a/server/wsproxy/constant.h +++ b/server/wsproxy/constant.h @@ -15,7 +15,6 @@ enum InnerMesssage_e IM_TargetConnDisconnect, IM_MasterSvrDisconnect, IM_TargetConnConnect, - IM_RequestTargetServerTimeout }; //网络处理对象 diff --git a/server/wsproxy/mastersvrmgr.cc b/server/wsproxy/mastersvrmgr.cc index c953bec..64e79b9 100644 --- a/server/wsproxy/mastersvrmgr.cc +++ b/server/wsproxy/mastersvrmgr.cc @@ -45,6 +45,7 @@ void MasterSvrMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ f8::MsgHdr* context_hdr = GetHdrByContextId(msg.context_id()); if (context_hdr) { bool auto_free = true; + int socket_handle = context_hdr->socket_handle; if (msg.error_code() == 0) { TargetConn* conn = TargetConnMgr::Instance()->RecreateTargetConn( msg.host(), @@ -56,7 +57,7 @@ void MasterSvrMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ conn->ForwardClientMsgEx(context_hdr); } } - RemoveRequest(context_hdr->socket_handle, msg.context_id(), auto_free); + RemoveRequest(socket_handle, msg.context_id(), auto_free); } } @@ -107,10 +108,11 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_ .SetParam1(hdr.socket_handle), [] (const a8::XParams& param) { - App::Instance()->AddIMMsg(IM_RequestTargetServerTimeout, - a8::XParams() - .SetSender(param.sender) - .SetParam1(param.param1)); + MasterSvrMgr::Instance()->RemoveRequest( + param.param1, + param.sender, + true + ); }, &timer_attacher->timer_list_); } @@ -119,18 +121,18 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_ void MasterSvrMgr::RemoveRequest(int socket_handle, long long context_id, bool auto_free) { if (context_id == GetContextIdBySocket(socket_handle)) { - f8::MsgHdr* hdr = GetHdrByContextId(context_id); - if (hdr) { - a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data; - delete timer_attacher; - if (auto_free) { + if (auto_free) { + f8::MsgHdr* hdr = GetHdrByContextId(context_id); + if (hdr) { + a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data; + delete timer_attacher; if (hdr->buf) { free((char*)hdr->buf); } free(hdr); } - pending_request_hash_.erase(context_id); } + pending_request_hash_.erase(context_id); pending_socket_hash_.erase(socket_handle); } }