1
This commit is contained in:
parent
59b94bced1
commit
fb9fefd1aa
@ -87,7 +87,7 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
int is_reconnect,
|
||||
int proto_version)
|
||||
{
|
||||
if (GetContextIdBySocket(hdr.socket_handle) != 0) {
|
||||
if (GetRequestBySocket(hdr.socket_handle)) {
|
||||
return;
|
||||
}
|
||||
unsigned int code = 0;
|
||||
@ -121,9 +121,9 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
msg.set_proto_version(proto_version);
|
||||
svr->SendMsg(msg);
|
||||
|
||||
pending_socket_hash_[hdr.socket_handle] = curr_context_id_;
|
||||
assert(pending_request_hash_.find(curr_context_id_) == pending_request_hash_.end());
|
||||
pending_request_hash_[curr_context_id_] = req;
|
||||
pending_socket_hash_[hdr.socket_handle] = req;
|
||||
assert(pending_context_hash_.find(curr_context_id_) == pending_context_hash_.end());
|
||||
pending_context_hash_[curr_context_id_] = req;
|
||||
req->timer_wp = f8::Timer::Instance()->SetTimeoutWp
|
||||
(1000 * 10,
|
||||
[req] (int event, const a8::Args* args)
|
||||
@ -148,6 +148,7 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
|
||||
void MasterMgr::RemoveRequest(int socket_handle, long long context_id, bool auto_free)
|
||||
{
|
||||
#if 0
|
||||
if (context_id == GetContextIdBySocket(socket_handle)) {
|
||||
auto req = GetRequestByContextId(context_id);
|
||||
if (req) {
|
||||
@ -158,19 +159,20 @@ void MasterMgr::RemoveRequest(int socket_handle, long long context_id, bool auto
|
||||
free(req->hdr_copy);
|
||||
}
|
||||
}
|
||||
pending_request_hash_.erase(context_id);
|
||||
pending_context_hash_.erase(context_id);
|
||||
pending_socket_hash_.erase(socket_handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
long long MasterMgr::GetContextIdBySocket(int socket_handle)
|
||||
std::shared_ptr<RequestTarget> MasterMgr::GetRequestBySocket(int socket_handle)
|
||||
{
|
||||
auto itr = pending_socket_hash_.find(socket_handle);
|
||||
return itr != pending_socket_hash_.end() ? itr->second : 0;
|
||||
return itr != pending_socket_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<RequestTarget> MasterMgr::GetRequestByContextId(long long context_id)
|
||||
{
|
||||
auto itr = pending_request_hash_.find(context_id);
|
||||
return itr != pending_request_hash_.end() ? itr->second : nullptr;
|
||||
auto itr = pending_context_hash_.find(context_id);
|
||||
return itr != pending_context_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
@ -36,14 +36,14 @@ class MasterMgr : public a8::Singleton<MasterMgr>
|
||||
void RemoveRequest(int socket_handle, long long context_id, bool auto_free);
|
||||
|
||||
private:
|
||||
long long GetContextIdBySocket(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);
|
||||
|
||||
private:
|
||||
long long curr_context_id_ = 0;
|
||||
std::map<int, std::shared_ptr<Master>> mastersvr_hash_;
|
||||
std::map<int, long long> pending_socket_hash_;
|
||||
std::map<long long, std::shared_ptr<RequestTarget>> pending_request_hash_;
|
||||
std::map<int, std::shared_ptr<RequestTarget>> pending_socket_hash_;
|
||||
std::map<long long, std::shared_ptr<RequestTarget>> pending_context_hash_;
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user