From 97efa02a1269abf346addf50eb9b9eb360d90685 Mon Sep 17 00:00:00 2001 From: thassss Date: Thu, 29 Jun 2017 09:26:20 -0700 Subject: [PATCH] Pass NULL to grpc_channel_create_call for nil serverName --- src/objective-c/GRPCClient/private/GRPCChannel.m | 11 ++++++++--- src/objective-c/GRPCClient/private/GRPCHost.m | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 845197126bc..d37c2b2a4e3 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -198,15 +198,20 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) { - (grpc_call *)unmanagedCallWithPath:(NSString *)path serverName:(NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue { - grpc_slice host_slice = grpc_slice_from_copied_string(serverName.UTF8String); + grpc_slice host_slice; + if (serverName) { + host_slice = grpc_slice_from_copied_string(serverName.UTF8String); + } grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String); grpc_call *call = grpc_channel_create_call(_unmanagedChannel, NULL, GRPC_PROPAGATE_DEFAULTS, queue.unmanagedQueue, path_slice, - &host_slice, + serverName ? &host_slice : NULL, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); - grpc_slice_unref(host_slice); + if (serverName) { + grpc_slice_unref(host_slice); + } grpc_slice_unref(path_slice); return call; } diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 2d88de18c19..13a9af9af5b 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -145,8 +145,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; } channel = _channel; } - NSString *name = serverName ? serverName : _address; - return [channel unmanagedCallWithPath:path serverName:name completionQueue:queue]; + return [channel unmanagedCallWithPath:path serverName:serverName completionQueue:queue]; } - (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts