fixed invalid DNS cancel

This commit is contained in:
WolverinDEV 2019-10-26 12:34:14 +01:00
parent b6dade6fc8
commit 62bd63b6a9
2 changed files with 10 additions and 5 deletions

View File

@ -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 {

View File

@ -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);
}
};