diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index 5766f931..5e790290 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -1113,6 +1113,9 @@ namespace client void ClientDestination::Start () { + // Idempotent: a second Start() on a running destination must not re-create + // m_StreamingDestination (orphaning the live one) nor re-arm leaseset/pool. + if (m_StreamingDestination) return; LeaseSetDestination::Start (); m_StreamingDestination = std::make_shared (GetSharedFromThis ()); // TODO: m_StreamingDestination->Start (); diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index 24917625..34c24f54 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -1378,7 +1378,9 @@ namespace client void SAMSingleSession::StopLocalDestination () { - localDestination->Release (); + // Destination is ref-counted and may be shared by sessions whose SESSION + // CREATEs resolve to the same identity hash; only its last user may stop it. + if (localDestination->Release () > 0) return; // stop accepting new streams localDestination->StopAcceptingStreams (); // terminate existing streams