Skip to content

Commit

Permalink
Make quit function thread safe (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demilivor authored Feb 2, 2025
1 parent a3b4779 commit f5de41f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/src/HttpAppFrameworkImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1044,7 +1044,6 @@ void HttpAppFrameworkImpl::quit()
pluginsManagerPtr_.reset();
redisClientManagerPtr_.reset();
dbClientManagerPtr_.reset();
running_ = false;
getLoop()->quit();
for (trantor::EventLoop *loop : ioLoopThreadPool_->getLoops())
{
Expand Down

0 comments on commit f5de41f

Please sign in to comment.