From 62bd63b6a927ba5fc09d516724a5bc3be60b0680 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 26 Oct 2019 12:34:14 +0100 Subject: [PATCH] fixed invalid DNS cancel --- native/dns/src/resolver_windows.cpp | 8 +++++--- native/dns/utils.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/native/dns/src/resolver_windows.cpp b/native/dns/src/resolver_windows.cpp index 728e1db..c3d0989 100644 --- a/native/dns/src/resolver_windows.cpp +++ b/native/dns/src/resolver_windows.cpp @@ -263,10 +263,10 @@ void Resolver::evtimer_dns_callback(Resolver::dns_request *request) { auto err = this->dnsapi.DnsCancelQuery(&request->dns_cancel); if(err != 0) std::cerr << "Failed to cancel timeouted DNS request" << std::endl; + } else { + request->callback(ResultState::DNS_TIMEOUT, 0, nullptr); + this->destroy_dns_request(request); } - - request->callback(ResultState::DNS_TIMEOUT, 0, nullptr); - this->destroy_dns_request(request); } void Resolver::dns_callback(Resolver::dns_request *request) { @@ -274,6 +274,8 @@ void Resolver::dns_callback(Resolver::dns_request *request) { auto status = request->dns_result.QueryStatus; if(status >= DNS_ERROR_RESPONSE_CODES_BASE && status <= DNS_ERROR_RCODE_LAST) request->callback(ResultState::DNS_FAIL, request->dns_result.QueryStatus - DNS_ERROR_RESPONSE_CODES_BASE, nullptr); + else if(status == ERROR_CANCELLED) + request->callback(ResultState::DNS_TIMEOUT, 0, nullptr); else request->callback(ResultState::DNS_API_FAIL, request->dns_result.QueryStatus, nullptr); } else { diff --git a/native/dns/utils.cpp b/native/dns/utils.cpp index b922284..73803ad 100644 --- a/native/dns/utils.cpp +++ b/native/dns/utils.cpp @@ -330,6 +330,7 @@ struct CrStatus { assert(this->pending > 0); if(--pending == 0 && !this->finished) { //Order matters we have to decrease pensing! + this->print_status(); this->callback(false, "no results"); this->finished = true; return; @@ -399,15 +400,17 @@ struct CrStatus { else \ std::cout << #element << ": success: " << std::get<2>(element).host << ":" << std::get<2>(element).port << std::endl; - void call_answer(const tc::dns::ServerAddress& data) { + void print_status() { answer_log(this->subsrv_ts, this->execute_subsrv_ts); answer_log(this->subsrv_ts3, this->execute_subsrv_ts3); answer_log(this->tsdns, this->execute_tsdns); answer_log(this->subdomain, this->execute_subdomain); answer_log(this->rootsrv, this->execute_rootsrv); answer_log(this->rootdomain, this->execute_rootdomain); + } - //TODO: Print data + void call_answer(const tc::dns::ServerAddress& data) { + this->print_status(); this->callback(true, data); } };