Merge pull request #195 from cbess/patch-1

Improved reachability check, detects severed internet connections.
This commit is contained in:
Mattt Thompson 2012-01-29 19:40:02 -08:00
commit 37559c792c

View file

@ -222,7 +222,11 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
static void AFReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
if (info) {
AFNetworkReachabilityStatusBlock block = (AFNetworkReachabilityStatusBlock)info;
BOOL isNetworkReachable = (flags & kSCNetworkReachabilityFlagsReachable);
BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
BOOL isNetworkReachable = (isReachable && !needsConnection);
block(isNetworkReachable);
}
}