[Nearby] Acquire mutex in ClientProxy::GetLocalEndpointId

This method is called from multiple threads and needs to ensure the local_endpoint_id_ data member can be read/updated safely from multiple threads.

PiperOrigin-RevId: 384337724
This commit is contained in:
James Vecore
2021-07-12 16:06:22 -07:00
committed by Copybara-Service
parent 7c2e204b2c
commit ea231c7138
+1
View File
@@ -48,6 +48,7 @@ ClientProxy::~ClientProxy() { Reset(); }
std::int64_t ClientProxy::GetClientId() const { return client_id_; }
std::string ClientProxy::GetLocalEndpointId() {
MutexLock lock(&mutex_);
if (local_endpoint_id_.empty()) {
local_endpoint_id_ = GenerateLocalEndpointId();
NEARBY_LOGS(INFO) << "ClientProxy [Local Endpoint Generated]: client="