Merge pull request #15086 from grpc/fix-channel-refcount

Fix _channel ref count issue
pull/14888/head
Muxi Yan 7 years ago committed by GitHub
commit 95fc9b897b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/objective-c/GRPCClient/private/GRPCHost.m

@ -108,7 +108,10 @@ static NSMutableDictionary *kHostCache;
serverName:(NSString *)serverName
timeout:(NSTimeInterval)timeout
completionQueue:(GRPCCompletionQueue *)queue {
GRPCChannel *channel;
// The __block attribute is to allow channel take refcount inside @synchronized block. Without
// this attribute, retain of channel object happens after objc_sync_exit in release builds, which
// may result in channel released before used. See grpc/#15033.
__block GRPCChannel *channel;
// This is racing -[GRPCHost disconnect].
@synchronized(self) {
if (!_channel) {

Loading…
Cancel
Save