This commit is contained in:
azw 2023-04-11 13:17:12 +00:00
parent 48fffc757d
commit 6c1441cd8f
3 changed files with 30 additions and 39 deletions

View File

@ -39,5 +39,3 @@ const int POSTFIX_LEN = 7;
const int MAX_NODE_ID = 8; const int MAX_NODE_ID = 8;
const int MAX_INSTANCE_ID = 500; const int MAX_INSTANCE_ID = 500;
const char* const azw_account_id = "6001_2001_oJqfX5c4pvW-wlarmcrvEO6BQjd8";

View File

@ -11,6 +11,7 @@
#include "upstreammgr.h" #include "upstreammgr.h"
#include "GCListener.h" #include "GCListener.h"
#include "app.h" #include "app.h"
#include "mastermgr.h"
struct PendingAccount struct PendingAccount
{ {
@ -49,9 +50,7 @@ void DownStreamMgr::OnClientDisconnect(int socket_handle)
socket_hash_.erase(socket_handle); socket_hash_.erase(socket_handle);
} }
RemovePendingAccount(socket_handle); RemovePendingAccount(socket_handle);
#if 0 MasterMgr::Instance()->RemoveRequest(socket_handle, 0, true);
MasterMgr::Instance()->RemoveRequest(pdelnode->params.param1, pdelnode->params.sender, true);
#endif
} }
void DownStreamMgr::OnUpStreamDisconnect(int instance_id) 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->socket_handle = socket_handle;
down->conn = conn; down->conn = conn;
socket_hash_[down->socket_handle] = down; 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)) { if (auto pending_account = GetPendingAccount(socket_handle)) {
long long cur_tick = a8::XGetTickCount(); long long cur_tick = a8::XGetTickCount();

View File

@ -45,15 +45,17 @@ void MasterMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_Res
if (context_hdr) { if (context_hdr) {
int socket_handle = context_hdr->socket_handle; int socket_handle = context_hdr->socket_handle;
if (msg.error_code() == 0) { if (msg.error_code() == 0) {
UpStream* conn = UpStreamMgr::Instance()->RecreateUpStream( UpStream* conn = UpStreamMgr::Instance()->RecreateUpStream
msg.host(), (
msg.port() msg.host(),
); msg.port()
assert(conn); );
if (conn) { if (conn) {
RemoveRequest(socket_handle, msg.context_id(), false); RemoveRequest(socket_handle, msg.context_id(), false);
conn->ForwardClientMsgEx(context_hdr); conn->ForwardClientMsgEx(context_hdr);
return; return;
} else {
abort();
} }
} }
RemoveRequest(socket_handle, msg.context_id(), true); RemoveRequest(socket_handle, msg.context_id(), true);
@ -96,8 +98,11 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
++curr_context_id_; ++curr_context_id_;
#if 0 #if 0
a8::TimerAttacher* timer_attacher = new a8::TimerAttacher(); a8::TimerAttacher* timer_attacher = new a8::TimerAttacher();
#endif
f8::MsgHdr* new_hdr = hdr.Clone(); f8::MsgHdr* new_hdr = hdr.Clone();
#if 0
new_hdr->user_data = timer_attacher; new_hdr->user_data = timer_attacher;
#endif
ss::SS_WSP_RequestTargetServer msg; ss::SS_WSP_RequestTargetServer msg;
msg.set_context_id(curr_context_id_); 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_; pending_socket_hash_[hdr.socket_handle] = curr_context_id_;
assert(pending_request_hash_.find(curr_context_id_) == pending_request_hash_.end()); assert(pending_request_hash_.find(curr_context_id_) == pending_request_hash_.end());
pending_request_hash_[curr_context_id_] = new_hdr; pending_request_hash_[curr_context_id_] = new_hdr;
if (account_id == azw_account_id) { #if 0
a8::UdpLog::Instance()->Info("%s request", {account_id});
}
auto timer_func = auto timer_func =
[] (const a8::XParams& param) [] (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()); a8::Timer::Instance()->RemoveTimerAfterFunc(a8::Timer::Instance()->GetRunningTimer());
MasterMgr::Instance()->RemoveRequest( MasterMgr::Instance()->RemoveRequest(
param.param1, param.param1,
@ -133,42 +130,37 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
auto timer_after_func = auto timer_after_func =
[] (const a8::XParams& param) [] (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(); long long req_handle_time = a8::XGetTickCount() - param.param3.GetInt64();
if (req_handle_time > App::Instance()->perf.max_login_time) { if (req_handle_time > App::Instance()->perf.max_login_time) {
App::Instance()->perf.max_login_time = req_handle_time; App::Instance()->perf.max_login_time = req_handle_time;
} }
DownStreamMgr::Instance()->AddPendingAccount(param.param2.GetString(), param.param1, param.param3); DownStreamMgr::Instance()->AddPendingAccount(param.param2.GetString(), param.param1, param.param3);
}; };
a8::Timer::Instance()->AddDeadLineTimerAndAttach(1000 * 10, f8::Timer::Instance()->SetTimeout
a8::XParams() (1000 * 10,
.SetSender(curr_context_id_) a8::XParams()
.SetParam1(hdr.socket_handle) .SetSender(curr_context_id_)
.SetParam2(account_id) .SetParam1(hdr.socket_handle)
.SetParam3(a8::XGetTickCount()), .SetParam2(account_id)
timer_func, .SetParam3(a8::XGetTickCount()),
&timer_attacher->timer_list_, timer_func,
timer_after_func &timer_attacher->timer_list_,
); timer_after_func
);
#endif #endif
} }
} }
void MasterMgr::RemoveRequest(int socket_handle, long long context_id, bool auto_free) void MasterMgr::RemoveRequest(int socket_handle, long long context_id, bool auto_free)
{ {
#if 0
if (context_id == GetContextIdBySocket(socket_handle)) { if (context_id == GetContextIdBySocket(socket_handle)) {
f8::MsgHdr* hdr = GetHdrByContextId(context_id); f8::MsgHdr* hdr = GetHdrByContextId(context_id);
if (hdr) { if (hdr) {
#if 0
a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data; a8::TimerAttacher* timer_attacher = (a8::TimerAttacher*)hdr->user_data;
delete timer_attacher; delete timer_attacher;
hdr->user_data = nullptr; hdr->user_data = nullptr;
#endif
if (auto_free) { if (auto_free) {
if (hdr->buf) { if (hdr->buf) {
free((char*)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_request_hash_.erase(context_id);
pending_socket_hash_.erase(socket_handle); pending_socket_hash_.erase(socket_handle);
} }
#endif
} }
long long MasterMgr::GetContextIdBySocket(int socket_handle) long long MasterMgr::GetContextIdBySocket(int socket_handle)