This commit is contained in:
aozhiwei 2023-04-24 11:19:49 +08:00
parent 0c1f08b877
commit 0ddb1e12ef
3 changed files with 18 additions and 7 deletions

View File

@ -5,6 +5,17 @@
#include "ss_proto.pb.h" #include "ss_proto.pb.h"
void DownStream::Init(int socket_handle, std::weak_ptr<UpStream> up)
{
socket_handle_ = socket_handle;
up_ = up;
}
void DownStream::ReBindUpStream(std::weak_ptr<UpStream> up)
{
up_ = up;
}
void DownStream::ForwardUpStreamMsg(f8::MsgHdr& hdr) void DownStream::ForwardUpStreamMsg(f8::MsgHdr& hdr)
{ {

View File

@ -5,10 +5,11 @@ class DownStream
{ {
public: public:
int GetSocketHandle() { return socket_handle_; } void Init(int socket_handle, std::weak_ptr<UpStream> up);
void SetSocketHandle(int socket_handle) { socket_handle_ = socket_handle; }
std::weak_ptr<UpStream> GetUpStream() { return up_; } int GetSocketHandle() const { return socket_handle_; }
void SetUpStream(std::weak_ptr<UpStream> up) { up_ = up; } std::weak_ptr<UpStream> GetUpStream() const { return up_; }
void ReBindUpStream(std::weak_ptr<UpStream> up);
void ForwardUpStreamMsg(f8::MsgHdr& hdr); void ForwardUpStreamMsg(f8::MsgHdr& hdr);
void OnClose(); void OnClose();

View File

@ -83,11 +83,10 @@ void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
if (!up_wp.expired()) { if (!up_wp.expired()) {
auto down_wp = GetDownStream(socket_handle); auto down_wp = GetDownStream(socket_handle);
if (auto down = down_wp.lock(); !down_wp.expired()) { if (auto down = down_wp.lock(); !down_wp.expired()) {
down->SetUpStream(up_wp); down->ReBindUpStream(up_wp);
} else { } else {
down = std::make_shared<DownStream>(); down = std::make_shared<DownStream>();
down->SetSocketHandle(socket_handle); down->Init(socket_handle, up_wp);
down->SetUpStream(up_wp);
socket_hash_[down->GetSocketHandle()] = down; socket_hash_[down->GetSocketHandle()] = down;
f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d", f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d",
{ {