1
This commit is contained in:
parent
48fffc757d
commit
6c1441cd8f
@ -39,5 +39,3 @@ const int POSTFIX_LEN = 7;
|
||||
|
||||
const int MAX_NODE_ID = 8;
|
||||
const int MAX_INSTANCE_ID = 500;
|
||||
|
||||
const char* const azw_account_id = "6001_2001_oJqfX5c4pvW-wlarmcrvEO6BQjd8";
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "upstreammgr.h"
|
||||
#include "GCListener.h"
|
||||
#include "app.h"
|
||||
#include "mastermgr.h"
|
||||
|
||||
struct PendingAccount
|
||||
{
|
||||
@ -49,9 +50,7 @@ void DownStreamMgr::OnClientDisconnect(int socket_handle)
|
||||
socket_hash_.erase(socket_handle);
|
||||
}
|
||||
RemovePendingAccount(socket_handle);
|
||||
#if 0
|
||||
MasterMgr::Instance()->RemoveRequest(pdelnode->params.param1, pdelnode->params.sender, true);
|
||||
#endif
|
||||
MasterMgr::Instance()->RemoveRequest(socket_handle, 0, true);
|
||||
}
|
||||
|
||||
void DownStreamMgr::OnUpStreamDisconnect(int instance_id)
|
||||
@ -92,7 +91,10 @@ void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
|
||||
down->socket_handle = socket_handle;
|
||||
down->conn = conn;
|
||||
socket_hash_[down->socket_handle] = down;
|
||||
f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d", {socket_handle});
|
||||
f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d",
|
||||
{
|
||||
socket_handle
|
||||
});
|
||||
{
|
||||
if (auto pending_account = GetPendingAccount(socket_handle)) {
|
||||
long long cur_tick = a8::XGetTickCount();
|
||||
|
@ -45,15 +45,17 @@ void MasterMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_Res
|
||||
if (context_hdr) {
|
||||
int socket_handle = context_hdr->socket_handle;
|
||||
if (msg.error_code() == 0) {
|
||||
UpStream* conn = UpStreamMgr::Instance()->RecreateUpStream(
|
||||
msg.host(),
|
||||
msg.port()
|
||||
);
|
||||
assert(conn);
|
||||
UpStream* conn = UpStreamMgr::Instance()->RecreateUpStream
|
||||
(
|
||||
msg.host(),
|
||||
msg.port()
|
||||
);
|
||||
if (conn) {
|
||||
RemoveRequest(socket_handle, msg.context_id(), false);
|
||||
conn->ForwardClientMsgEx(context_hdr);
|
||||
return;
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
RemoveRequest(socket_handle, msg.context_id(), true);
|
||||
@ -96,8 +98,11 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
++curr_context_id_;
|
||||
#if 0
|
||||
a8::TimerAttacher* timer_attacher = new a8::TimerAttacher();
|
||||
#endif
|
||||
f8::MsgHdr* new_hdr = hdr.Clone();
|
||||
#if 0
|
||||
new_hdr->user_data = timer_attacher;
|
||||
#endif
|
||||
|
||||
ss::SS_WSP_RequestTargetServer msg;
|
||||
msg.set_context_id(curr_context_id_);
|
||||
@ -111,18 +116,10 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
pending_socket_hash_[hdr.socket_handle] = curr_context_id_;
|
||||
assert(pending_request_hash_.find(curr_context_id_) == pending_request_hash_.end());
|
||||
pending_request_hash_[curr_context_id_] = new_hdr;
|
||||
if (account_id == azw_account_id) {
|
||||
a8::UdpLog::Instance()->Info("%s request", {account_id});
|
||||
}
|
||||
#if 0
|
||||
auto timer_func =
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
if (param.param2.GetString() == azw_account_id) {
|
||||
a8::UdpLog::Instance()->Info("%s timeout",
|
||||
{
|
||||
param.param2.GetString()
|
||||
});
|
||||
}
|
||||
a8::Timer::Instance()->RemoveTimerAfterFunc(a8::Timer::Instance()->GetRunningTimer());
|
||||
MasterMgr::Instance()->RemoveRequest(
|
||||
param.param1,
|
||||
@ -133,42 +130,37 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
auto timer_after_func =
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
if (param.param2.GetString() == azw_account_id) {
|
||||
a8::UdpLog::Instance()->Info("%s response time:%d",
|
||||
{
|
||||
param.param2.GetString(),
|
||||
a8::XGetTickCount() - param.param3.GetInt64()
|
||||
});
|
||||
}
|
||||
long long req_handle_time = a8::XGetTickCount() - param.param3.GetInt64();
|
||||
if (req_handle_time > App::Instance()->perf.max_login_time) {
|
||||
App::Instance()->perf.max_login_time = req_handle_time;
|
||||
}
|
||||
DownStreamMgr::Instance()->AddPendingAccount(param.param2.GetString(), param.param1, param.param3);
|
||||
};
|
||||
a8::Timer::Instance()->AddDeadLineTimerAndAttach(1000 * 10,
|
||||
a8::XParams()
|
||||
.SetSender(curr_context_id_)
|
||||
.SetParam1(hdr.socket_handle)
|
||||
.SetParam2(account_id)
|
||||
.SetParam3(a8::XGetTickCount()),
|
||||
timer_func,
|
||||
&timer_attacher->timer_list_,
|
||||
timer_after_func
|
||||
);
|
||||
f8::Timer::Instance()->SetTimeout
|
||||
(1000 * 10,
|
||||
a8::XParams()
|
||||
.SetSender(curr_context_id_)
|
||||
.SetParam1(hdr.socket_handle)
|
||||
.SetParam2(account_id)
|
||||
.SetParam3(a8::XGetTickCount()),
|
||||
timer_func,
|
||||
&timer_attacher->timer_list_,
|
||||
timer_after_func
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void MasterMgr::RemoveRequest(int socket_handle, long long context_id, bool auto_free)
|
||||
{
|
||||
#if 0
|
||||
if (context_id == GetContextIdBySocket(socket_handle)) {
|
||||
f8::MsgHdr* hdr = GetHdrByContextId(context_id);
|
||||
if (hdr) {
|
||||
#if 0
|
||||
a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data;
|
||||
delete timer_attacher;
|
||||
hdr->user_data = nullptr;
|
||||
#endif
|
||||
if (auto_free) {
|
||||
if (hdr->buf) {
|
||||
free((char*)hdr->buf);
|
||||
@ -179,7 +171,6 @@ void MasterMgr::RemoveRequest(int socket_handle, long long context_id, bool auto
|
||||
pending_request_hash_.erase(context_id);
|
||||
pending_socket_hash_.erase(socket_handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
long long MasterMgr::GetContextIdBySocket(int socket_handle)
|
||||
|
Loading…
x
Reference in New Issue
Block a user