fixed dns lib for linux
This commit is contained in:
+11
-3
@@ -13,10 +13,10 @@
|
||||
#include <cstring>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/inet.h>
|
||||
#else
|
||||
#include <Ws2ipdef.h>
|
||||
#include <ip2string.h>
|
||||
#include <Ws2ipdef.h>
|
||||
#include <ip2string.h>
|
||||
#endif
|
||||
|
||||
using namespace tc::dns;
|
||||
@@ -181,7 +181,11 @@ void tc::dns::cr_srv(Resolver& resolver, const ServerAddress& address, const cr_
|
||||
for(auto [priority, pentries] : entries) {
|
||||
uint32_t count = 0;
|
||||
for(const auto& entry : pentries) {
|
||||
#ifdef WIN32
|
||||
count += max((size_t) entry.weight, 1UL);
|
||||
#else
|
||||
count += std::max((size_t) entry.weight, 1UL);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::uniform_int_distribution<std::mt19937::result_type> dist(0, (uint32_t) (count - 1));
|
||||
@@ -189,7 +193,11 @@ void tc::dns::cr_srv(Resolver& resolver, const ServerAddress& address, const cr_
|
||||
|
||||
count = 0;
|
||||
for(const auto& entry : pentries) {
|
||||
#ifdef WIN32
|
||||
count += max((size_t) entry.weight, 1UL);
|
||||
#else
|
||||
count += std::max((size_t) entry.weight, 1UL);
|
||||
#endif
|
||||
if(count > index) {
|
||||
count = -1;
|
||||
results.emplace_back(priority, entry);
|
||||
|
||||
Reference in New Issue
Block a user