From 39e1c883b643a265c928487a0da0092300cb7508 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 24 Apr 2023 11:08:56 +0800 Subject: [PATCH] 1 --- server/wsproxy/downstreammgr.cc | 2 +- server/wsproxy/upstreammgr.cc | 12 ++++++------ server/wsproxy/upstreammgr.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/wsproxy/downstreammgr.cc b/server/wsproxy/downstreammgr.cc index cad716c..374624d 100644 --- a/server/wsproxy/downstreammgr.cc +++ b/server/wsproxy/downstreammgr.cc @@ -79,7 +79,7 @@ std::weak_ptr DownStreamMgr::GetDownStream(int sockhandle) void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id) { - std::weak_ptr conn = UpStreamMgr::Instance()->GetConnById(conn_instance_id); + std::weak_ptr 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()) { diff --git a/server/wsproxy/upstreammgr.cc b/server/wsproxy/upstreammgr.cc index 2083dcb..86b7c74 100644 --- a/server/wsproxy/upstreammgr.cc +++ b/server/wsproxy/upstreammgr.cc @@ -15,7 +15,7 @@ void UpStreamMgr::Init() [this] (const a8::Args& args) { int instance_id = args.Get(0); - std::weak_ptr conn = GetConnById(instance_id); + std::weak_ptr conn = GetUpStreamById(instance_id); if (!conn.expired() && conn.lock()->Connected()) { conn.lock()->SendStockMsg(); } @@ -35,13 +35,13 @@ void UpStreamMgr::UnInit() } } -std::weak_ptr UpStreamMgr::GetConnByKey(const std::string& key) +std::weak_ptr UpStreamMgr::GetUpStreamByKey(const std::string& key) { auto itr = key_hash_.find(key); return itr != key_hash_.end() ? itr->second : nullptr; } -std::weak_ptr UpStreamMgr::GetConnById(int instance_id) +std::weak_ptr 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 UpStreamMgr::GetConnById(int instance_id) std::weak_ptr 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; diff --git a/server/wsproxy/upstreammgr.h b/server/wsproxy/upstreammgr.h index 5bcdd4f..cdb9a1f 100644 --- a/server/wsproxy/upstreammgr.h +++ b/server/wsproxy/upstreammgr.h @@ -14,8 +14,8 @@ class UpStreamMgr : public a8::Singleton void Init(); void UnInit(); - std::weak_ptr GetConnByKey(const std::string& key); - std::weak_ptr GetConnById(int instance_id); + std::weak_ptr GetUpStreamByKey(const std::string& key); + std::weak_ptr GetUpStreamById(int instance_id); std::weak_ptr RecreateUpStream(const std::string& host, int port); private: