aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/GRPCCall.m
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-08-06 18:55:45 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-08-06 18:55:45 -0700
commite8f0e54dce41e4575cc48c390f6d7696be27f22a (patch)
tree73d0b2213547898a3c3c88f8850012c12786da86 /src/objective-c/GRPCClient/GRPCCall.m
parent6499836bdac014b0b30cc28fd0e9c9bc07c76bcd (diff)
Enable CFStream with environment variable
Diffstat (limited to 'src/objective-c/GRPCClient/GRPCCall.m')
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 9783b06440..b8337ab0cd 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -45,6 +45,8 @@ static NSMutableDictionary *callFlags;
static NSString *const kAuthorizationHeader = @"authorization";
static NSString *const kBearerPrefix = @"Bearer ";
+const char *kCFStreamVarName = "grpc_cfstream";
+
@interface GRPCCall ()<GRXWriteable>
// Make them read-write.
@property(atomic, strong) NSDictionary *responseHeaders;
@@ -206,9 +208,12 @@ static NSString *const kBearerPrefix = @"Bearer ";
} else {
[_responseWriteable enqueueSuccessfulCompletion];
}
-#ifndef GRPC_CFSTREAM
- [GRPCConnectivityMonitor unregisterObserver:self];
-#endif
+
+ // Connectivity monitor is not required for CFStream
+ char *enableCFStream = getenv(kCFStreamVarName);
+ if (enableCFStream == nil || enableCFStream[0] != '1') {
+ [GRPCConnectivityMonitor unregisterObserver:self];
+ }
// If the call isn't retained anywhere else, it can be deallocated now.
_retainSelf = nil;
@@ -463,9 +468,11 @@ static NSString *const kBearerPrefix = @"Bearer ";
[self sendHeaders:_requestHeaders];
[self invokeCall];
-#ifndef GRPC_CFSTREAM
- [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChanged:)];
-#endif
+ // Connectivity monitor is not required for CFStream
+ char *enableCFStream = getenv(kCFStreamVarName);
+ if (enableCFStream == nil || enableCFStream[0] != '1') {
+ [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChanged:)];
+ }
}
- (void)startWithWriteable:(id<GRXWriteable>)writeable {