From 9ae3aeb12f32f472177fd8ba9b1f13437f180044 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 7 Jun 2018 18:15:54 -0700 Subject: Do not register connectivity monitor if using CFStream --- src/objective-c/GRPCClient/GRPCCall.m | 5 ++++- src/objective-c/GRPCClient/private/GRPCHost.m | 4 ++++ .../tests/Connectivity/ConnectivityTestingApp/ViewController.m | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 5b48d06158..9783b06440 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -206,8 +206,9 @@ static NSString *const kBearerPrefix = @"Bearer "; } else { [_responseWriteable enqueueSuccessfulCompletion]; } - +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor unregisterObserver:self]; +#endif // If the call isn't retained anywhere else, it can be deallocated now. _retainSelf = nil; @@ -462,7 +463,9 @@ static NSString *const kBearerPrefix = @"Bearer "; [self sendHeaders:_requestHeaders]; [self invokeCall]; +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChanged:)]; +#endif } - (void)startWithWriteable:(id)writeable { diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index bd5fd94118..ac448d0696 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -49,7 +49,9 @@ static NSMutableDictionary *kHostCache; if (_channelCreds != nil) { grpc_channel_credentials_release(_channelCreds); } +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor unregisterObserver:self]; +#endif } // Default initializer. @@ -84,7 +86,9 @@ static NSMutableDictionary *kHostCache; kHostCache[address] = self; _compressAlgorithm = GRPC_COMPRESS_NONE; } +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChange:)]; +#endif } return self; } diff --git a/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m b/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m index 88780e39f0..3c77fe2f2c 100644 --- a/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m +++ b/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m @@ -35,7 +35,9 @@ NSString *host = @"grpc-test.sandbox.googleapis.com"; - (void)viewDidLoad { [super viewDidLoad]; +#ifndef GRPC_CFSTREAM [GRPCConnectivityMonitor registerObserver:self selector:@selector(reachabilityChanged:)]; +#endif } - (void)reachabilityChanged:(NSNotification *)note { -- cgit v1.2.3 From be9b5d14379206779055f8ded18d280e88ec3ffe Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 8 Jun 2018 17:42:23 -0700 Subject: Update connectivity test --- .../ConnectivityTestingApp.xcodeproj/project.pbxproj | 17 +---------------- src/objective-c/tests/Connectivity/Podfile | 6 +++--- 2 files changed, 4 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj b/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj index 6a4c3519d6..7a03f9b41a 100644 --- a/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Connectivity/ConnectivityTestingApp.xcodeproj/project.pbxproj @@ -99,7 +99,6 @@ 5EC49F8D2043E46B00ED189A /* Sources */, 5EC49F8E2043E46B00ED189A /* Frameworks */, 5EC49F8F2043E46B00ED189A /* Resources */, - 9F67C72B6B6BAF2781078886 /* [CP] Embed Pods Frameworks */, 735516C793AF7394FBB83B7F /* [CP] Copy Pods Resources */, ); buildRules = ( @@ -194,21 +193,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 9F67C72B6B6BAF2781078886 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ConnectivityTestingApp/Pods-ConnectivityTestingApp-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -284,6 +268,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", + "GRPC_CFSTREAM=1", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; diff --git a/src/objective-c/tests/Connectivity/Podfile b/src/objective-c/tests/Connectivity/Podfile index cdbc6dde59..c7127b3e78 100644 --- a/src/objective-c/tests/Connectivity/Podfile +++ b/src/objective-c/tests/Connectivity/Podfile @@ -5,9 +5,9 @@ platform :ios, '8.0' GRPC_LOCAL_SRC = '../../../..' target 'ConnectivityTestingApp' do - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC/CFStream', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core/CFStream-Implementation', :path => GRPC_LOCAL_SRC + pod 'gRPC-ProtoRPC/CFStream', :path => GRPC_LOCAL_SRC pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf" pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" -- cgit v1.2.3