From 4e9b535a59861f25c0602eaa1fc39126d7cd9899 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz>
Date: Thu, 7 Aug 2025 12:21:54 +0200
Subject: [PATCH 13/38] fix a possible bad_weak_ptr exception
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires

Change-Id: I8c7f7a943a1d848f15527988cb76c2a0a10089e6
Fixes: 4eae6200 (close long-lived connections on SIGTERM)
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
 src/http/EventStream.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/http/EventStream.cpp b/src/http/EventStream.cpp
index 3bdd55e..8703dad 100644
--- a/src/http/EventStream.cpp
+++ b/src/http/EventStream.cpp
@@ -47,7 +47,7 @@ EventStream::EventStream(const server::request& req,
         }
 
         state = WantToClose;
-        boost::asio::post(this->res.io_service(), [weak = std::weak_ptr<EventStream>{shared_from_this()}]() {
+        boost::asio::post(this->res.io_service(), [weak = weak_from_this()]() {
             if (auto myself = weak.lock()) {
                 std::lock_guard lock{myself->mtx};
                 if (myself->state == WantToClose) { // resume unless somebody closed it before this was picked up by the event loop
-- 
2.43.0

