prevent race condition in datagram destination

clean up style a bit
This commit is contained in:
Jeff Becker 2016-09-03 10:24:06 -04:00
parent caace05ba6
commit c770bcbf96
No known key found for this signature in database
GPG key ID: AB950234D6EA286B
4 changed files with 34 additions and 21 deletions

View file

@ -543,11 +543,12 @@ namespace client
auto dest = i2p::client::context.GetSharedLocalDestination ();
if (dest)
{
auto datagram = dest->GetDatagramDestination ();
if(datagram == nullptr) datagram = dest->CreateDatagramDestination();
datagram->SetReceiver (std::bind (&AddressBook::HandleLookupResponse, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
if (!datagram)
datagram = dest->CreateDatagramDestination ();
datagram->SetReceiver (std::bind (&AddressBook::HandleLookupResponse, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5),
ADDRESS_RESPONSE_DATAGRAM_PORT);
}
}
@ -557,8 +558,7 @@ namespace client
if (dest)
{
auto datagram = dest->GetDatagramDestination ();
if (datagram)
datagram->ResetReceiver ();
if (datagram) datagram->ResetReceiver (ADDRESS_RESPONSE_DATAGRAM_PORT);
}
}