|
|
@ -68,8 +68,7 @@ namespace data |
|
|
|
dest->SetRequestComplete (requestComplete); |
|
|
|
dest->SetRequestComplete (requestComplete); |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex); |
|
|
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex); |
|
|
|
if (!m_RequestedDestinations.insert (std::make_pair (destination, |
|
|
|
if (!m_RequestedDestinations.insert (std::make_pair (destination, dest)).second) // not inserted
|
|
|
|
std::shared_ptr<RequestedDestination> (dest))).second) // not inserted
|
|
|
|
|
|
|
|
return nullptr; |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
return dest; |
|
|
|
return dest; |
|
|
@ -77,20 +76,28 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
void NetDbRequests::RequestComplete (const IdentHash& ident, std::shared_ptr<RouterInfo> r) |
|
|
|
void NetDbRequests::RequestComplete (const IdentHash& ident, std::shared_ptr<RouterInfo> r) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::shared_ptr<RequestedDestination> request; |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex); |
|
|
|
auto it = m_RequestedDestinations.find (ident); |
|
|
|
auto it = m_RequestedDestinations.find (ident); |
|
|
|
if (it != m_RequestedDestinations.end ()) |
|
|
|
if (it != m_RequestedDestinations.end ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
request = it->second; |
|
|
|
|
|
|
|
m_RequestedDestinations.erase (it); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (r) |
|
|
|
if (r) |
|
|
|
it->second->Success (r); |
|
|
|
request->Success (r); |
|
|
|
else |
|
|
|
else |
|
|
|
it->second->Fail (); |
|
|
|
request->Fail (); |
|
|
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex); |
|
|
|
|
|
|
|
m_RequestedDestinations.erase (it); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<RequestedDestination> NetDbRequests::FindRequest (const IdentHash& ident) const |
|
|
|
std::shared_ptr<RequestedDestination> NetDbRequests::FindRequest (const IdentHash& ident) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex); |
|
|
|
auto it = m_RequestedDestinations.find (ident); |
|
|
|
auto it = m_RequestedDestinations.find (ident); |
|
|
|
if (it != m_RequestedDestinations.end ()) |
|
|
|
if (it != m_RequestedDestinations.end ()) |
|
|
|
return it->second; |
|
|
|
return it->second; |
|
|
|