diff --git a/server/wsproxy/downstreammgr.cc b/server/wsproxy/downstreammgr.cc index ef99152..e809994 100644 --- a/server/wsproxy/downstreammgr.cc +++ b/server/wsproxy/downstreammgr.cc @@ -47,7 +47,7 @@ void DownStreamMgr::OnClientDisconnect(int socket_handle) socket_hash_.erase(socket_handle); } RemovePendingAccount(socket_handle); - MasterMgr::Instance()->RemoveRequest(socket_handle); + MasterMgr::Instance()->OnDownStreamDisconnect(socket_handle); } void DownStreamMgr::OnUpStreamDisconnect(int instance_id) diff --git a/server/wsproxy/mastermgr.cc b/server/wsproxy/mastermgr.cc index 61926c0..30a8550 100644 --- a/server/wsproxy/mastermgr.cc +++ b/server/wsproxy/mastermgr.cc @@ -126,6 +126,10 @@ void MasterMgr::_SS_MS_HttpTunnelResponse(f8::MsgHdr* hdr, const ss::SS_MS_HttpT ); if (!conn.expired()) { ss::SS_HttpTunnelRequest msg; + msg.set_context_id(msg.context_id()); + msg.set_socket_handle(msg.socket_handle()); + msg.set_url(msg.url()); + msg.set_query_str(msg.query_str()); conn.lock()->SendMsg(req->socket_handle, msg); return; } else { @@ -135,6 +139,9 @@ void MasterMgr::_SS_MS_HttpTunnelResponse(f8::MsgHdr* hdr, const ss::SS_MS_HttpT req->request->GetResp()->SetVal("errcode", 500); req->request->GetResp()->SetVal("errmsg", "server internal error"); req->request->Response(); + if (!req->timer_wp.expired()) { + f8::Timer::Instance()->Delete(req->timer_wp); + } RemoveHttpTunnelRequest(req->socket_handle); } } @@ -247,6 +254,19 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr* hdr, } } +void MasterMgr::OnDownStreamDisconnect(int socket_handle) +{ + { + auto req = GetHttpTunnelRequestBySocket(socket_handle); + if (req) { + if (!req->timer_wp.expired()) { + f8::Timer::Instance()->Delete(req->timer_wp); + } + } + } + RemoveRequest(socket_handle); +} + void MasterMgr::RemoveRequest(int socket_handle) { { diff --git a/server/wsproxy/mastermgr.h b/server/wsproxy/mastermgr.h index 95a2f0f..ddb9b0c 100644 --- a/server/wsproxy/mastermgr.h +++ b/server/wsproxy/mastermgr.h @@ -39,10 +39,11 @@ class MasterMgr : public a8::Singleton const std::string& server_info, int is_reconnect, int proto_version); - void RemoveRequest(int socket_handle); + void OnDownStreamDisconnect(int socket_handle); void AddHttpTunnelRequest(int socket_handle, std::shared_ptr request); private: + void RemoveRequest(int socket_handle); std::shared_ptr GetHttpTunnelRequestBySocket(int socket_handle); std::shared_ptr GetHttpTunnelRequestByContextId(long long conext_id); std::shared_ptr GetRequestBySocket(int socket_handle);