From 5b703b2e44c477ee7d0c2d78db30153647f3f48c Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Sun, 19 Feb 2023 22:03:20 +0100
Subject: [PATCH] fix: Stop I/O handling before forwarding the dtor
 notification

---
 src/net/tcp_client.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/net/tcp_client.cpp b/src/net/tcp_client.cpp
index ae237d2..7103ed1 100644
--- a/src/net/tcp_client.cpp
+++ b/src/net/tcp_client.cpp
@@ -160,11 +160,11 @@ tcp_client::tcp_client(
 {}
 
 tcp_client::~tcp_client() {
-    if (destructor_cb != nullptr) {
+    io.stop();
+
+    if (destructor_cb) {
         destructor_cb(exit_status_t::NO_ERROR);
     }
-
-    io.stop();
 }
 
 void tcp_client::write_data(const std::string &data) {
-- 
GitLab