diff options
author | Muxi Yan <mxyan@google.com> | 2018-10-16 17:39:51 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2018-10-16 17:39:51 -0700 |
commit | a8b07a37df7680bbe853f4efa0c358447db946fe (patch) | |
tree | c30d4033b54b44ae47b1bb9c5f59ebdb65c969ac /src | |
parent | 7d32a2cb25275e03a44184ad9f8a3e494e62dd0d (diff) |
Synchronized access to kHostCache
Diffstat (limited to 'src')
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCHost.m | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 429958b408..de6f09a44b 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -125,7 +125,10 @@ static NSMutableDictionary *kHostCache; if (hostURL.host && !hostURL.port) { address = [hostURL.host stringByAppendingString:@":443"]; } - GRPCHost *cachedHost = kHostCache[address]; + __block GRPCHost *cachedHost; + @synchronized (kHostCache) { + cachedHost = kHostCache[address]; + } return (cachedHost != nil); } |