reference counter for destinations
This commit is contained in:
@@ -13,13 +13,21 @@ namespace client
|
||||
m_LocalDestination (localDestination ? localDestination :
|
||||
i2p::client::context.CreateNewLocalDestination (false, I2P_SERVICE_DEFAULT_KEY_TYPE))
|
||||
{
|
||||
m_LocalDestination->Acquire ();
|
||||
}
|
||||
|
||||
I2PService::I2PService (i2p::data::SigningKeyType kt):
|
||||
m_LocalDestination (i2p::client::context.CreateNewLocalDestination (false, kt))
|
||||
{
|
||||
m_LocalDestination->Acquire ();
|
||||
}
|
||||
|
||||
I2PService::~I2PService ()
|
||||
{
|
||||
ClearHandlers ();
|
||||
if (m_LocalDestination) m_LocalDestination->Release ();
|
||||
}
|
||||
|
||||
void I2PService::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) {
|
||||
assert(streamRequestComplete);
|
||||
i2p::data::IdentHash identHash;
|
||||
|
@@ -19,7 +19,7 @@ namespace client
|
||||
public:
|
||||
I2PService (std::shared_ptr<ClientDestination> localDestination = nullptr);
|
||||
I2PService (i2p::data::SigningKeyType kt);
|
||||
virtual ~I2PService () { ClearHandlers (); }
|
||||
virtual ~I2PService ();
|
||||
|
||||
inline void AddHandler (std::shared_ptr<I2PServiceHandler> conn)
|
||||
{
|
||||
|
@@ -921,6 +921,7 @@ namespace client
|
||||
}
|
||||
if (localDestination)
|
||||
{
|
||||
localDestination->Acquire ();
|
||||
auto session = std::make_shared<SAMSession>(localDestination);
|
||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||
auto ret = m_Sessions.insert (std::make_pair(id, session));
|
||||
@@ -945,6 +946,7 @@ namespace client
|
||||
}
|
||||
if (session)
|
||||
{
|
||||
session->localDestination->Release ();
|
||||
session->localDestination->StopAcceptingStreams ();
|
||||
session->CloseStreams ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user