fixed dns lib for linux
This commit is contained in:
parent
b9bd60f4e1
commit
55f3f7656a
@ -4,7 +4,7 @@ set(SOURCE_FILES ${SOURCE_FILES} src/resolver.cpp src/types.cpp src/response.cpp
|
||||
if (WIN32)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} src/resolver_windows.cpp)
|
||||
else()
|
||||
set(SOURCE_FILES ${SOURCE_FILES} src/resolver_linux.cpp src/resolver_windows.cpp)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} src/resolver_linux.cpp)
|
||||
endif()
|
||||
|
||||
find_package(Libevent REQUIRED)
|
||||
|
@ -85,6 +85,9 @@ NAN_METHOD(query_connect_address) {
|
||||
});
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
__attribute__((visibility("default")))
|
||||
#endif
|
||||
NAN_MODULE_INIT(init) {
|
||||
Nan::Set(target,
|
||||
v8::String::NewFromUtf8(Nan::GetCurrentContext()->GetIsolate(), "resolve_cr").ToLocalChecked(),
|
||||
|
@ -54,7 +54,7 @@ void Resolver::destroy_dns_request(Resolver::dns_request *request) {
|
||||
}
|
||||
|
||||
if(!this->event.loop_active)
|
||||
ub_cancel(this->ub_ctx, entry->ub_id);
|
||||
ub_cancel(this->ub_ctx, request->ub_id);
|
||||
|
||||
if(request->register_event) {
|
||||
event_del_noblock(request->register_event);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user