This commit is contained in:
azw 2023-04-09 08:59:03 +00:00
parent 89816f516a
commit 71175471e1
2 changed files with 27 additions and 26 deletions

View File

@ -12,6 +12,14 @@
#include "GCListener.h" #include "GCListener.h"
#include "app.h" #include "app.h"
struct PendingAccount
{
int socket_handle = 0;
std::string account_id;
long long add_tick = 0;
f8::TimerWp timer_wp;
};
void DownStreamMgr::Init() void DownStreamMgr::Init()
{ {
f8::MsgQueue::Instance()->RegisterCallBack f8::MsgQueue::Instance()->RegisterCallBack
@ -27,9 +35,7 @@ void DownStreamMgr::Init()
void DownStreamMgr::UnInit() void DownStreamMgr::UnInit()
{ {
socket_hash_.clear(); socket_hash_.clear();
#if 0
pending_account_hash_.clear(); pending_account_hash_.clear();
#endif
} }
void DownStreamMgr::OnClientDisconnect(int socket_handle) void DownStreamMgr::OnClientDisconnect(int socket_handle)
@ -90,26 +96,17 @@ void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
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 0 if (auto pending_account = GetPendingAccount(socket_handle)) {
auto itr = pending_account_hash_.find(socket_handle);
if (itr != pending_account_hash_.end()) {
std::string account_id = std::get<0>(itr->second);
long long req_tick = std::get<1>(itr->second);
long long cur_tick = a8::XGetTickCount(); long long cur_tick = a8::XGetTickCount();
if (cur_tick - req_tick > App::Instance()->perf.max_join_time) { if (cur_tick - pending_account->add_tick > App::Instance()->perf.max_join_time) {
App::Instance()->perf.max_join_time = cur_tick - req_tick; App::Instance()->perf.max_join_time = cur_tick - pending_account->add_tick;
} }
if (account_id == azw_account_id) { f8::UdpLog::Instance()->Info("BindUpStream account_id:%s",
f8::UdpLog::Instance()->Info("%s join time:%d", {
{ pending_account->account_id
account_id, });
cur_tick - req_tick
});
}
f8::UdpLog::Instance()->Info("BindUpStream account_id:%s", {account_id});
RemovePendingAccount(socket_handle); RemovePendingAccount(socket_handle);
} }
#endif
} }
} }
} }
@ -141,16 +138,20 @@ void DownStreamMgr::AddPendingAccount(const std::string& account_id, int socket_
#endif #endif
} }
std::shared_ptr<PendingAccount> DownStreamMgr::GetPendingAccount(int socket_handle)
{
auto itr = pending_account_hash_.find(socket_handle);
return itr != pending_account_hash_.end() ? itr->second : nullptr;
}
void DownStreamMgr::RemovePendingAccount(int socket_handle) void DownStreamMgr::RemovePendingAccount(int socket_handle)
{ {
#if 0
f8::UdpLog::Instance()->Info("RemovePendingAccount %d", {socket_handle}); f8::UdpLog::Instance()->Info("RemovePendingAccount %d", {socket_handle});
auto itr = pending_account_hash_.find(socket_handle); auto itr = pending_account_hash_.find(socket_handle);
if (itr != pending_account_hash_.end()) { if (itr != pending_account_hash_.end()) {
#if 0 if (!itr->second->timer_wp.expired()) {
f8::Timer::Instance()->DeleteTimer(std::get<2>(itr->second)); f8::Timer::Instance()->Delete(itr->second->timer_wp);
}
pending_account_hash_.erase(itr); pending_account_hash_.erase(itr);
#endif
} }
#endif
} }

View File

@ -3,6 +3,7 @@
#include <f8/timer.h> #include <f8/timer.h>
class DownStream; class DownStream;
struct PendingAccount;
class DownStreamMgr : public a8::Singleton<DownStreamMgr> class DownStreamMgr : public a8::Singleton<DownStreamMgr>
{ {
private: private:
@ -25,12 +26,11 @@ class DownStreamMgr : public a8::Singleton<DownStreamMgr>
private: private:
void OnClientDisconnect(int socket_handle); void OnClientDisconnect(int socket_handle);
std::shared_ptr<PendingAccount> GetPendingAccount(int socket_handle);
void RemovePendingAccount(int socket_handle); void RemovePendingAccount(int socket_handle);
private: private:
a8::Attacher timer_attacher_; a8::Attacher timer_attacher_;
std::map<int, std::shared_ptr<DownStream>> socket_hash_; std::map<int, std::shared_ptr<DownStream>> socket_hash_;
#if 0 std::map<int, std::shared_ptr<PendingAccount>> pending_account_hash_;
std::map<int, std::tuple<std::string, long long, timer_list*>> pending_account_hash_;
#endif
}; };