remove some unnecessary check

This commit is contained in:
XieHan
2021-01-30 16:05:25 +08:00
parent 2849529958
commit 349083e0fc
+12 -34
View File
@@ -137,12 +137,6 @@ void WFResolverTask::dispatch()
this->state = WFT_STATE_SYS_ERROR;
this->error = errno;
}
else if (!this->result.request_object)
{
//should not happen
this->state = WFT_STATE_SYS_ERROR;
this->error = EAGAIN;
}
else
this->state = WFT_STATE_SUCCESS;
@@ -230,40 +224,24 @@ void WFResolverTask::dns_callback_internal(DNSOutput *dns_out,
}
else
{
auto *route_manager = WFGlobal::get_route_manager();
auto *dns_cache = WFGlobal::get_dns_cache();
struct addrinfo *addrinfo = dns_out->move_addrinfo();
const DNSHandle *addr_handle;
if (addrinfo)
addr_handle = dns_cache->put(host_, port_, addrinfo,
(unsigned int)ttl_default,
(unsigned int)ttl_min);
if (route_manager->get(type_, addrinfo, info_, &endpoint_params_,
this->result) < 0)
{
auto *route_manager = WFGlobal::get_route_manager();
auto *dns_cache = WFGlobal::get_dns_cache();
addr_handle = dns_cache->put(host_, port_, addrinfo,
(unsigned int)ttl_default,
(unsigned int)ttl_min);
if (route_manager->get(type_, addrinfo, info_, &endpoint_params_,
this->result) < 0)
{
this->state = WFT_STATE_SYS_ERROR;
this->error = errno;
}
else if (!this->result.request_object)
{
//should not happen
this->state = WFT_STATE_SYS_ERROR;
this->error = EAGAIN;
}
else
this->state = WFT_STATE_SUCCESS;
dns_cache->release(addr_handle);
this->state = WFT_STATE_SYS_ERROR;
this->error = errno;
}
else
{
//system promise addrinfo not null, here should not happen
this->state = WFT_STATE_SYS_ERROR;
this->error = EINVAL;
}
this->state = WFT_STATE_SUCCESS;
dns_cache->release(addr_handle);
}
}