This commit is contained in:
aozhiwei 2024-03-24 13:35:56 +08:00
parent 09ad4bea1d
commit b3f165760b
2 changed files with 8 additions and 6 deletions

View File

@ -234,19 +234,19 @@ std::shared_ptr<RequestTarget> MasterMgr::GetRequestByContextId(long long contex
void MasterMgr::AddHttpTunnelRequest(int socket_handle, std::shared_ptr<f8::JsonHttpRequest> request)
{
pending_http_tunnel_hash_[socket_handle] = request;
pending_http_tunnel_socket_hash_[socket_handle] = request;
}
void MasterMgr::RemoveHttpTunnelRequest(int socket_handle)
{
auto req = GetHttpTunnelRequest(socket_handle);
if (req) {
pending_http_tunnel_hash_.end();
pending_http_tunnel_socket_hash_.end();
}
}
std::shared_ptr<f8::JsonHttpRequest> MasterMgr::GetHttpTunnelRequest(int socket_handle)
{
auto itr = pending_http_tunnel_hash_.find(socket_handle);
return itr != pending_http_tunnel_hash_.end() ? itr->second : nullptr;
auto itr = pending_http_tunnel_socket_hash_.find(socket_handle);
return itr != pending_http_tunnel_socket_hash_.end() ? itr->second : nullptr;
}

View File

@ -38,18 +38,20 @@ class MasterMgr : public a8::Singleton<MasterMgr>
int proto_version);
void RemoveRequest(int socket_handle);
void AddHttpTunnelRequest(int socket_handle, std::shared_ptr<f8::JsonHttpRequest> request);
void RemoveHttpTunnelRequest(int socket_handle);
private:
std::shared_ptr<f8::JsonHttpRequest> GetHttpTunnelRequest(int socket_handle);
std::shared_ptr<RequestTarget> GetRequestBySocket(int socket_handle);
std::shared_ptr<RequestTarget> GetRequestByContextId(long long context_id);
std::shared_ptr<Master> GetConnById(int instance_id);
void RemoveHttpTunnelRequest(int socket_handle);
private:
long long curr_context_id_ = 0;
std::map<int, std::shared_ptr<Master>> mastersvr_hash_;
std::map<int, std::shared_ptr<RequestTarget>> pending_socket_hash_;
std::map<long long, std::shared_ptr<RequestTarget>> pending_context_hash_;
std::map<int, std::shared_ptr<f8::JsonHttpRequest>> pending_http_tunnel_hash_;
std::map<int, std::shared_ptr<f8::JsonHttpRequest>> pending_http_tunnel_socket_hash_;
};