From f5de41f5d7c364fec9764edc2e0d851b07c76621 Mon Sep 17 00:00:00 2001 From: Alexey Gerasimchuck Date: Mon, 3 Feb 2025 00:22:17 +1000 Subject: [PATCH] Make quit function thread safe (#2247) --- lib/src/HttpAppFrameworkImpl.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/HttpAppFrameworkImpl.cc b/lib/src/HttpAppFrameworkImpl.cc index 4c49c25934..42309eeb2d 100644 --- a/lib/src/HttpAppFrameworkImpl.cc +++ b/lib/src/HttpAppFrameworkImpl.cc @@ -1033,7 +1033,7 @@ HttpAppFramework &HttpAppFrameworkImpl::createRedisClient( void HttpAppFrameworkImpl::quit() { - if (getLoop()->isRunning()) + if (getLoop()->isRunning() && running_.exchange(false)) { getLoop()->queueInLoop([this]() { // Release members in the reverse order of initialization @@ -1044,7 +1044,6 @@ void HttpAppFrameworkImpl::quit() pluginsManagerPtr_.reset(); redisClientManagerPtr_.reset(); dbClientManagerPtr_.reset(); - running_ = false; getLoop()->quit(); for (trantor::EventLoop *loop : ioLoopThreadPool_->getLoops()) {