Skip to content

Commit

Permalink
Merge pull request #16 from DNSPod/feature/1.3.5
Browse files Browse the repository at this point in the history
feat:优化多线程逻辑
  • Loading branch information
ocleo1 authored Mar 14, 2022
2 parents 701743d + 6e5d349 commit 1aa96a4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions MSDKDns/CacheManager/MSDKDnsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,9 @@ - (BOOL) domianCache:(NSDictionary *)cache hit:(NSString *)domain {

# pragma mark - servers
- (NSString *)currentDnsServer {
if (self.serverIndex < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count]) {
return [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] objectAtIndex:self.serverIndex];
int index = self.serverIndex;
if (index < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count]) {
return [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] objectAtIndex:index];
}
return [[MSDKDnsParamsManager shareInstance] msdkDnsGetMDnsIp];
}
Expand All @@ -680,7 +681,7 @@ - (void)switchDnsServer {
}
self.waitToSwitch = YES;
dispatch_async([MSDKDnsInfoTool msdkdns_queue], ^{
if (self.serverIndex < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count]) {
if (self.serverIndex < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count] - 1) {
self.serverIndex += 1;
if (!self.firstFailTime) {
self.firstFailTime = [NSDate date];
Expand Down

0 comments on commit 1aa96a4

Please sign in to comment.