diff --git a/Datagram.cpp b/Datagram.cpp index f06d62da..2015622c 100644 --- a/Datagram.cpp +++ b/Datagram.cpp @@ -11,7 +11,7 @@ namespace i2p { namespace datagram { - DatagramDestination::DatagramDestination (std::shared_ptr owner): + DatagramDestination::DatagramDestination (std::shared_ptr owner): m_Owner (owner), m_Receiver (nullptr) { } diff --git a/Datagram.h b/Datagram.h index 404facf2..c593fad2 100644 --- a/Datagram.h +++ b/Datagram.h @@ -14,7 +14,7 @@ namespace i2p { namespace client { - class LeaseSetDestination; + class ClientDestination; } namespace datagram { @@ -25,7 +25,7 @@ namespace datagram public: - DatagramDestination (std::shared_ptr owner); + DatagramDestination (std::shared_ptr owner); ~DatagramDestination (); void SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash& ident, uint16_t fromPort = 0, uint16_t toPort = 0); @@ -47,7 +47,7 @@ namespace datagram private: - std::shared_ptr m_Owner; + std::shared_ptr m_Owner; Receiver m_Receiver; // default std::map m_ReceiversByPorts; diff --git a/Destination.cpp b/Destination.cpp index a7d33454..46ff688f 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -662,7 +662,7 @@ namespace client { if (LeaseSetDestination::Start ()) { - m_StreamingDestination = std::make_shared (shared_from_this ()); // TODO: + m_StreamingDestination = std::make_shared (GetSharedFromThis ()); // TODO: m_StreamingDestination->Start (); for (auto it: m_StreamingDestinationsByPorts) it.second->Start (); @@ -735,7 +735,7 @@ namespace client streamRequestComplete(CreateStream (leaseSet, port)); else { - auto s = std::static_pointer_cast(shared_from_this ()); + auto s = GetSharedFromThis (); RequestDestination (dest, [s, streamRequestComplete, port](std::shared_ptr ls) { @@ -788,7 +788,7 @@ namespace client std::shared_ptr ClientDestination::CreateStreamingDestination (int port, bool gzip) { - auto dest = std::make_shared (shared_from_this (), port, gzip); + auto dest = std::make_shared (GetSharedFromThis (), port, gzip); if (port) m_StreamingDestinationsByPorts[port] = dest; else // update default @@ -799,7 +799,7 @@ namespace client i2p::datagram::DatagramDestination * ClientDestination::CreateDatagramDestination () { if (!m_DatagramDestination) - m_DatagramDestination = new i2p::datagram::DatagramDestination (shared_from_this ()); + m_DatagramDestination = new i2p::datagram::DatagramDestination (GetSharedFromThis ()); return m_DatagramDestination; } diff --git a/Destination.h b/Destination.h index 85b4b5ab..4c8bfc80 100644 --- a/Destination.h +++ b/Destination.h @@ -174,7 +174,9 @@ namespace client private: void PersistTemporaryKeys (); - + std::shared_ptr GetSharedFromThis () + { return std::static_pointer_cast(shared_from_this ()); } + private: i2p::data::PrivateKeys m_Keys; diff --git a/Streaming.cpp b/Streaming.cpp index bf29caec..ab0a6df0 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -780,7 +780,7 @@ namespace stream m_CurrentRemoteLease = nullptr; } - StreamingDestination::StreamingDestination (std::shared_ptr owner, uint16_t localPort, bool gzip): + StreamingDestination::StreamingDestination (std::shared_ptr owner, uint16_t localPort, bool gzip): m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip), m_PendingIncomingTimer (m_Owner->GetService ()) { diff --git a/Streaming.h b/Streaming.h index 43061b94..c29b62f9 100644 --- a/Streaming.h +++ b/Streaming.h @@ -23,7 +23,7 @@ namespace i2p { namespace client { - class LeaseSetDestination; + class ClientDestination; } namespace stream { @@ -193,7 +193,7 @@ namespace stream typedef std::function)> Acceptor; - StreamingDestination (std::shared_ptr owner, uint16_t localPort = 0, bool gzip = true); + StreamingDestination (std::shared_ptr owner, uint16_t localPort = 0, bool gzip = true); ~StreamingDestination (); void Start (); @@ -204,7 +204,7 @@ namespace stream void SetAcceptor (const Acceptor& acceptor); void ResetAcceptor (); bool IsAcceptorSet () const { return m_Acceptor != nullptr; }; - std::shared_ptr GetOwner () const { return m_Owner; }; + std::shared_ptr GetOwner () const { return m_Owner; }; uint16_t GetLocalPort () const { return m_LocalPort; }; void HandleDataMessagePayload (const uint8_t * buf, size_t len); @@ -218,7 +218,7 @@ namespace stream private: - std::shared_ptr m_Owner; + std::shared_ptr m_Owner; uint16_t m_LocalPort; bool m_Gzip; // gzip compression of data messages std::mutex m_StreamsMutex;