修复宕机问题

This commit is contained in:
aozhiwei 2019-09-24 19:10:53 +08:00
parent 86bff0cb84
commit a9194a80af
2 changed files with 13 additions and 12 deletions

View File

@ -15,7 +15,6 @@ enum InnerMesssage_e
IM_TargetConnDisconnect, IM_TargetConnDisconnect,
IM_MasterSvrDisconnect, IM_MasterSvrDisconnect,
IM_TargetConnConnect, IM_TargetConnConnect,
IM_RequestTargetServerTimeout
}; };
//网络处理对象 //网络处理对象

View File

@ -45,6 +45,7 @@ void MasterSvrMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_
f8::MsgHdr* context_hdr = GetHdrByContextId(msg.context_id()); f8::MsgHdr* context_hdr = GetHdrByContextId(msg.context_id());
if (context_hdr) { if (context_hdr) {
bool auto_free = true; bool auto_free = true;
int socket_handle = context_hdr->socket_handle;
if (msg.error_code() == 0) { if (msg.error_code() == 0) {
TargetConn* conn = TargetConnMgr::Instance()->RecreateTargetConn( TargetConn* conn = TargetConnMgr::Instance()->RecreateTargetConn(
msg.host(), msg.host(),
@ -56,7 +57,7 @@ void MasterSvrMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_
conn->ForwardClientMsgEx(context_hdr); 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), .SetParam1(hdr.socket_handle),
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
App::Instance()->AddIMMsg(IM_RequestTargetServerTimeout, MasterSvrMgr::Instance()->RemoveRequest(
a8::XParams() param.param1,
.SetSender(param.sender) param.sender,
.SetParam1(param.param1)); true
);
}, },
&timer_attacher->timer_list_); &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) void MasterSvrMgr::RemoveRequest(int socket_handle, long long context_id, bool auto_free)
{ {
if (context_id == GetContextIdBySocket(socket_handle)) { if (context_id == GetContextIdBySocket(socket_handle)) {
if (auto_free) {
f8::MsgHdr* hdr = GetHdrByContextId(context_id); f8::MsgHdr* hdr = GetHdrByContextId(context_id);
if (hdr) { if (hdr) {
a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data; a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data;
delete timer_attacher; delete timer_attacher;
if (auto_free) {
if (hdr->buf) { if (hdr->buf) {
free((char*)hdr->buf); free((char*)hdr->buf);
} }
free(hdr); free(hdr);
} }
pending_request_hash_.erase(context_id);
} }
pending_request_hash_.erase(context_id);
pending_socket_hash_.erase(socket_handle); pending_socket_hash_.erase(socket_handle);
} }
} }