Locking around read/write to peering_endpoint. (#4019)

This commit is contained in:
clemahieu 2022-12-06 12:52:49 +00:00 committed by GitHub
commit c4111ea629
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,17 +81,20 @@ void nano::transport::channel::send (nano::message & message_a, std::function<vo
void nano::transport::channel::set_peering_endpoint (nano::endpoint endpoint)
{
nano::lock_guard<nano::mutex> lock{ channel_mutex };
peering_endpoint = endpoint;
}
nano::endpoint nano::transport::channel::get_peering_endpoint () const
{
nano::unique_lock<nano::mutex> lock{ channel_mutex };
if (peering_endpoint)
{
return *peering_endpoint;
}
else
{
lock.unlock ();
return get_endpoint ();
}
}