Skip to content

Commit

Permalink
feat:优化多线程逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Vastness committed Mar 14, 2022
1 parent 701743d commit 6e5d349
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 6e5d349

Please sign in to comment.