This commit is contained in:
aozhiwei 2023-04-24 11:08:56 +08:00
parent 5ed753636c
commit 39e1c883b6
3 changed files with 9 additions and 9 deletions

View File

@ -79,7 +79,7 @@ std::weak_ptr<DownStream> DownStreamMgr::GetDownStream(int sockhandle)
void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
{
std::weak_ptr<UpStream> conn = UpStreamMgr::Instance()->GetConnById(conn_instance_id);
std::weak_ptr<UpStream> conn = UpStreamMgr::Instance()->GetUpStreamById(conn_instance_id);
if (!conn.expired()) {
auto down_wp = GetDownStream(socket_handle);
if (auto down = down_wp.lock(); !down_wp.expired()) {

View File

@ -15,7 +15,7 @@ void UpStreamMgr::Init()
[this] (const a8::Args& args)
{
int instance_id = args.Get<int>(0);
std::weak_ptr<UpStream> conn = GetConnById(instance_id);
std::weak_ptr<UpStream> conn = GetUpStreamById(instance_id);
if (!conn.expired() && conn.lock()->Connected()) {
conn.lock()->SendStockMsg();
}
@ -35,13 +35,13 @@ void UpStreamMgr::UnInit()
}
}
std::weak_ptr<UpStream> UpStreamMgr::GetConnByKey(const std::string& key)
std::weak_ptr<UpStream> UpStreamMgr::GetUpStreamByKey(const std::string& key)
{
auto itr = key_hash_.find(key);
return itr != key_hash_.end() ? itr->second : nullptr;
}
std::weak_ptr<UpStream> UpStreamMgr::GetConnById(int instance_id)
std::weak_ptr<UpStream> UpStreamMgr::GetUpStreamById(int instance_id)
{
auto itr = id_hash_.find(instance_id);
return itr != id_hash_.end() ? itr->second : nullptr;
@ -50,10 +50,10 @@ std::weak_ptr<UpStream> UpStreamMgr::GetConnById(int instance_id)
std::weak_ptr<UpStream> UpStreamMgr::RecreateUpStream(const std::string& host, int port)
{
std::string key = host + ":" + a8::XValue(port).GetString();
if (!GetConnByKey(key).expired()) {
return GetConnByKey(key);
if (!GetUpStreamByKey(key).expired()) {
return GetUpStreamByKey(key);
}
while (!GetConnById(++curr_id_).expired()) {};
while (!GetUpStreamById(++curr_id_).expired()) {};
int instance_id = curr_id_;
std::string remote_ip = host;
int remote_port = port;

View File

@ -14,8 +14,8 @@ class UpStreamMgr : public a8::Singleton<UpStreamMgr>
void Init();
void UnInit();
std::weak_ptr<UpStream> GetConnByKey(const std::string& key);
std::weak_ptr<UpStream> GetConnById(int instance_id);
std::weak_ptr<UpStream> GetUpStreamByKey(const std::string& key);
std::weak_ptr<UpStream> GetUpStreamById(int instance_id);
std::weak_ptr<UpStream> RecreateUpStream(const std::string& host, int port);
private: