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); } }