Skip to content

Commit

Permalink
getNetworkConnectivityLevel can throw under some circumstances. Handle (
Browse files Browse the repository at this point in the history
microsoft#1795)

* getNetworkConnectivityLevel can throw under some circumstances.  Handle
these and treat the connection status as 'not connected'.
  • Loading branch information
Raj Seshasankaran authored and ashvarma committed Jan 25, 2017
1 parent ab08d24 commit b50e3e6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Frameworks/SystemConfiguration/SCNetworkReachability.mm
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,19 @@ + (void)_testAllReachabilityObjects {

+ (void)_checkGlobalReachability {
WNCConnectionProfile* internetConnectionProfile = [WNCNetworkInformation getInternetConnectionProfile];
if (internetConnectionProfile &&
[internetConnectionProfile getNetworkConnectivityLevel] == WNCNetworkConnectivityLevelInternetAccess) {
SCNetworkReachabilityFlags newFlags = kSCNetworkReachabilityFlagsReachable;
@try {
if (internetConnectionProfile &&
[internetConnectionProfile getNetworkConnectivityLevel] == WNCNetworkConnectivityLevelInternetAccess) {
SCNetworkReachabilityFlags newFlags = kSCNetworkReachabilityFlagsReachable;

if (internetConnectionProfile.isWwanConnectionProfile) {
newFlags |= kSCNetworkReachabilityFlagsIsWWAN;
if (internetConnectionProfile.isWwanConnectionProfile) {
newFlags |= kSCNetworkReachabilityFlagsIsWWAN;
}
_globalReachableFlags = newFlags;
} else {
_globalReachableFlags = 0;
}
_globalReachableFlags = newFlags;
} else {
} @catch (...) {
_globalReachableFlags = 0;
}
}
Expand Down Expand Up @@ -237,12 +241,11 @@ - (void)_availabilityChanged {
if (_callbackQueue != NULL && _isPerformingCallback == FALSE) {
_isPerformingCallback = TRUE;
[self retain];
dispatch_async(_callbackQueue,
^void() {
[self _performCallback];
[self release];
_isPerformingCallback = FALSE;
});
dispatch_async(_callbackQueue, ^void() {
[self _performCallback];
[self release];
_isPerformingCallback = FALSE;
});
}

[_reachabilityFlagsValid unlock];
Expand Down

0 comments on commit b50e3e6

Please sign in to comment.