From 07a2a70bca9a2ffa3c69b43a49f29c4d52808c98 Mon Sep 17 00:00:00 2001
From: Jorge Canizales <jcanizales@google.com>
Date: Fri, 11 Mar 2016 10:49:56 -0800
Subject: [PATCH] Not call external methods from within a critical section

---
 src/objective-c/GRPCClient/private/GRPCHost.m | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index b6a6d48d96..508cb20644 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -94,12 +94,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
                               completionQueue:(GRPCCompletionQueue *)queue {
+  GRPCChannel *channel;
+  // This is racing -[GRPCHost disconnect].
   @synchronized(self) {
     if (!_channel) {
       _channel = [self newChannel];
     }
-    return [_channel unmanagedCallWithPath:path completionQueue:queue];
+    channel = _channel;
   }
+  return [channel unmanagedCallWithPath:path completionQueue:queue];
 }
 
 - (NSDictionary *)channelArgs {
@@ -136,6 +139,7 @@ NS_ASSUME_NONNULL_BEGIN
 }
 
 - (void)disconnect {
+  // This is racing -[GRPCHost unmanagedCallWithPath:completionQueue:].
   @synchronized(self) {
     _channel = nil;
   }
-- 
GitLab