Skip to content
Snippets Groups Projects
Commit eacce164 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

namedirectory: prevent deadlock on destruction

The default status code of 0 is passed to the done callbacks when
the requests are destroyed. Returning from the callback when we get
this code prevents locking the mutex on multiple times on the same
thread.

Change-Id: I4e6da6de7b6572d6a0f744c3b90d1be28ad0298c
parent fc09b128
No related branches found
No related tags found
No related merge requests found
...@@ -162,6 +162,9 @@ NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb) ...@@ -162,6 +162,9 @@ NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb)
setHeaderFields(*request); setHeaderFields(*request);
request->add_on_done_callback( request->add_on_done_callback(
[this, cb = std::move(cb), reqid, addr](const dht::http::Response& response) { [this, cb = std::move(cb), reqid, addr](const dht::http::Response& response) {
if (response.status_code == 0) {
return;
}
if (response.status_code >= 400 && response.status_code < 500) { if (response.status_code >= 400 && response.status_code < 500) {
cb("", Response::notFound); cb("", Response::notFound);
} else if (response.status_code != 200) { } else if (response.status_code != 200) {
...@@ -248,6 +251,9 @@ NameDirectory::lookupName(const std::string& n, LookupCallback cb) ...@@ -248,6 +251,9 @@ NameDirectory::lookupName(const std::string& n, LookupCallback cb)
setHeaderFields(*request); setHeaderFields(*request);
request->add_on_done_callback([this, reqid, name, cb = std::move(cb)]( request->add_on_done_callback([this, reqid, name, cb = std::move(cb)](
const dht::http::Response& response) { const dht::http::Response& response) {
if (response.status_code == 0) {
return;
}
if (response.status_code >= 400 && response.status_code < 500) if (response.status_code >= 400 && response.status_code < 500)
cb("", Response::notFound); cb("", Response::notFound);
else if (response.status_code < 200 || response.status_code > 299) else if (response.status_code < 200 || response.status_code > 299)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment