Destroy DNS resolver of HttpClient in the correct thread (#490)

This commit is contained in:
An Tao 2020-06-22 19:55:24 +08:00 committed by GitHub
parent 3424d3f2c4
commit ccd51d289e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -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,