diff options
author | 2018-04-20 09:38:53 -0700 | |
---|---|---|
committer | 2018-04-20 09:38:53 -0700 | |
commit | 95fc9b897b444cc56d7f4d2b826bfd1b1c53ab58 (patch) | |
tree | db1cd5b786378df3e488a637abd743f4c3add53f /src | |
parent | 2a6f47354391af2514310ff06d44a26354cc07fb (diff) | |
parent | bc1a1b4411aa6e6e955a95f9219a9afb009274e6 (diff) |
Merge pull request #15086 from grpc/fix-channel-refcount
Fix _channel ref count issue
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 283306262a..bfb1fd352c 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/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) { |