From 91a2af0eda42370360f98cb7ee32de58e8d58493 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Mon, 1 Jun 2020 14:56:58 -0600 Subject: [PATCH] Sanity checks around shared_from_this() --- llarp/iwp/session.cpp | 2 ++ llarp/iwp/session.hpp | 6 ------ llarp/link/session.hpp | 5 ----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/llarp/iwp/session.cpp b/llarp/iwp/session.cpp index 2d642c15d..4004a8ea3 100644 --- a/llarp/iwp/session.cpp +++ b/llarp/iwp/session.cpp @@ -90,6 +90,7 @@ namespace llarp m_RemoteRC = msg->rc; GotLIM = util::memFn(&Session::GotRenegLIM, this); auto self = shared_from_this(); + assert(self.use_count() > 1); SendOurLIM([self](ILinkSession::DeliveryStatus st) { if (st == ILinkSession::DeliveryStatus::eDeliverySuccess) { @@ -241,6 +242,7 @@ namespace llarp } } auto self = shared_from_this(); + assert(self.use_count() > 1); if (m_EncryptNext && !m_EncryptNext->empty()) { m_Parent->QueueWork([self, data = std::move(m_EncryptNext)] { self->EncryptWorker(data); }); diff --git a/llarp/iwp/session.hpp b/llarp/iwp/session.hpp index fee4a2be0..4a67d4221 100644 --- a/llarp/iwp/session.hpp +++ b/llarp/iwp/session.hpp @@ -47,12 +47,6 @@ namespace llarp ~Session() = default; - std::shared_ptr - BorrowSelf() override - { - return shared_from_this(); - } - void Pump() override; diff --git a/llarp/link/session.hpp b/llarp/link/session.hpp index cb8920acf..199b14996 100644 --- a/llarp/link/session.hpp +++ b/llarp/link/session.hpp @@ -26,11 +26,6 @@ namespace llarp eDeliveryDropped = 1 }; - /// equiv of shared_from_this but for the interface type so - /// that each implementation can use shared_from_this - virtual std::shared_ptr - BorrowSelf() = 0; - /// hook for utp for when we have established a connection virtual void OnLinkEstablished(ILinkLayer*){};