From 0dbf6c8d727c9f905458c81043f8fbad07ca5c58 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 31 Dec 2023 21:59:45 +0800 Subject: [PATCH] Ensure thread safety for TcpServer's deconstruction (#200) --- src/Network/TcpServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Network/TcpServer.cpp b/src/Network/TcpServer.cpp index 1b0f0d1c7..9055117e1 100644 --- a/src/Network/TcpServer.cpp +++ b/src/Network/TcpServer.cpp @@ -76,7 +76,7 @@ void TcpServer::setOnCreateSocket(Socket::onCreateSocket cb) { } TcpServer::Ptr TcpServer::onCreatServer(const EventPoller::Ptr &poller) { - return std::make_shared(poller); + return Ptr(new TcpServer(poller), [poller](TcpServer *ptr) { poller->async([ptr]() { delete ptr; }); }); } Socket::Ptr TcpServer::onBeforeAcceptConnection(const EventPoller::Ptr &poller) {