From faa016af542763492a63de8cc972f8f4b52a58cd Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Sun, 1 Feb 2026 17:42:32 +0100 Subject: [PATCH] refactor: Use aliasing shared_ptr in Sock::Wait --- src/util/sock.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/sock.cpp b/src/util/sock.cpp index ba822a0eaf7..752fb327d9c 100644 --- a/src/util/sock.cpp +++ b/src/util/sock.cpp @@ -138,10 +138,12 @@ bool Sock::IsSelectable() const bool Sock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred) const { - // We need a `shared_ptr` owning `this` for `WaitMany()`, but don't want + // We need a `shared_ptr` holding `this` for `WaitMany()`, but don't want // `this` to be destroyed when the `shared_ptr` goes out of scope at the - // end of this function. Create it with a custom noop deleter. - std::shared_ptr shared{this, [](const Sock*) {}}; + // end of this function. + // Create it with an aliasing shared_ptr that points to `this` without + // owning it. + std::shared_ptr shared{std::shared_ptr{}, this}; EventsPerSock events_per_sock{std::make_pair(shared, Events{requested})};