aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2016-10-20 18:03:24 -0700
committerGravatar Muxi Yan <mxyan@google.com>2016-10-20 18:03:24 -0700
commit0a18d64fccb9f42a6dd6efcfb1634d541b09af81 (patch)
treec6fdf0571b001eb4a20e1d557c643f65e9842bd7 /src/objective-c/GRPCClient
parent72e92441f78dd5f51b0c1787b66d3b41e8f8767f (diff)
Address the comments
Diffstat (limited to 'src/objective-c/GRPCClient')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m11
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m3
-rw-r--r--src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h3
3 files changed, 7 insertions, 10 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
index afd773c70c..b2a10db432 100644
--- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
+++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
@@ -130,13 +130,7 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
if ((self = [super init])) {
_reachabilityRef = CFRetain(reachability);
_queue = dispatch_get_main_queue();
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) {
- _previousReachabilityFlags =
- [[GRPCReachabilityFlags alloc] initWithFlags:flags];
- } else {
- _previousReachabilityFlags = 0;
- }
+ _previousReachabilityFlags = nil;
}
return self;
}
@@ -162,7 +156,8 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
[self startListeningWithHandler:^(GRPCReachabilityFlags *flags) {
if (!flags.reachable) {
handler();
- } else if (flags.isWWAN ^ _previousReachabilityFlags.isWWAN) {
+ } else if (!_previousReachabilityFlags ||
+ (flags.isWWAN ^ _previousReachabilityFlags.isWAAN)) {
wifiStatusChangeHandler();
}
_previousReachabilityFlags = flags;
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index ee6045653e..256278bd49 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -101,6 +101,9 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
_secure = YES;
kHostCache[address] = self;
+ // When there is host in the cache, keep a single monitor to the network
+ // to
+ // flush the cache if the connectivity status changed
if (!connectivityMonitor) {
connectivityMonitor =
[GRPCConnectivityMonitor monitorWithHost:hostURL.host];
diff --git a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h b/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
index 1c907877a0..f5b9e7e64c 100644
--- a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
+++ b/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
@@ -55,7 +55,7 @@
#endif
#if TARGET_OS_IPHONE
-GRPC_XMACRO_ITEM(isCell, IsWWAN)
+GRPC_XMACRO_ITEM(isWWAN, IsWWAN)
#endif
GRPC_XMACRO_ITEM(reachable, Reachable)
GRPC_XMACRO_ITEM(transientConnection, TransientConnection)
@@ -65,4 +65,3 @@ GRPC_XMACRO_ITEM(interventionRequired, InterventionRequired)
GRPC_XMACRO_ITEM(connectionOnDemand, ConnectionOnDemand)
GRPC_XMACRO_ITEM(isLocalAddress, IsLocalAddress)
GRPC_XMACRO_ITEM(isDirect, IsDirect)
-GRPC_XMACRO_ITEM(isWWAN, IsWWAN)