diff --git a/lib/src/HttpClientImpl.cc b/lib/src/HttpClientImpl.cc index 7e5c1548..e02ac352 100644 --- a/lib/src/HttpClientImpl.cc +++ b/lib/src/HttpClientImpl.cc @@ -192,6 +192,11 @@ HttpClientImpl::HttpClientImpl(trantor::EventLoop *loop, HttpClientImpl::~HttpClientImpl() { LOG_TRACE << "Deconstruction HttpClient"; + if (resolverPtr_ && !(loop_->isInLoopThread())) + { + // Make sure the resolverPtr_ is destroyed in the correct thread. + loop_->queueInLoop([reolverPtr = resolverPtr_]() {}); + } } void HttpClientImpl::sendRequest(const drogon::HttpRequestPtr &req,