From 3fc5ca0c75aae97e9201df000a5afd5f628403b8 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 12 Dec 2018 14:30:12 -0800 Subject: [PATCH] batch fix --- .../GRPCClient/private/GRPCInsecureChannelFactory.m | 2 +- src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m | 2 +- src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m index b802137c13a..8ad1e848f55 100644 --- a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m @@ -33,7 +33,7 @@ } - (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args { - grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs([args copy]); + grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs(args); grpc_channel *unmanagedChannel = grpc_insecure_channel_create(host.UTF8String, coreChannelArgs, NULL); GRPCFreeChannelArgs(coreChannelArgs); diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m index 3ccc70a7448..96998895364 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m @@ -119,7 +119,7 @@ if (host.length == 0) { return NULL; } - grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs([args copy]); + grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs(args); grpc_channel *unmanagedChannel = grpc_secure_channel_create(_channelCreds, host.UTF8String, coreChannelArgs, NULL); GRPCFreeChannelArgs(coreChannelArgs); diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 4edd9d3e378..1a848a4b7c3 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -307,6 +307,10 @@ - (void)channelDisconnected { @synchronized(self) { if (_call != NULL) { + // Unreference the call will lead to its cancellation in the core. Note that since + // this function is only called with a network state change, any existing GRPCCall object will + // also receive the same notification and cancel themselves with GRPCErrorCodeUnavailable, so + // the user gets GRPCErrorCodeUnavailable in this case. grpc_call_unref(_call); _call = NULL; }