From b484e2e49b9f9d06a0313dd82936017d58f9c5d4 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 20 Jul 2020 19:56:38 +0000 Subject: [PATCH] Decouple checking tenancy from checking for metadata server --- .../credentials/google_default/google_default_credentials.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 2c292e6a116..4ed18a4c606 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -285,7 +285,11 @@ static void update_tenancy() { g_metadata_server_available = g_is_on_gce; } /* TODO: Add a platform-provided hint for GAE. */ + gpr_mu_unlock(&g_state_mu); +} +static void update_metadata_server_available() { + gpr_mu_lock(&g_state_mu); /* Do a network test for metadata server. */ if (!g_metadata_server_available) { g_metadata_server_available = is_metadata_server_reachable(); @@ -349,6 +353,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create( update_tenancy(); if (call_creds == nullptr) { + update_metadata_server_available(); call_creds = make_default_call_creds(&error); }