Skip to content

Commit

Permalink
Merge pull request grpc#15086 from grpc/fix-channel-refcount
Browse files Browse the repository at this point in the history
Fix _channel ref count issue
  • Loading branch information
muxi committed Apr 20, 2018
2 parents 2a6f473 + bc1a1b4 commit 95fc9b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/objective-c/GRPCClient/private/GRPCHost.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ - (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
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) {
Expand Down

0 comments on commit 95fc9b8

Please sign in to comment.