- HttpTransact::SM_ACTION_DNS_LOOKUP; - HttpTransact::ORIGIN_SERVER_RAW_OPEN; - HttpTransact::ORIGIN_SERVER_OPEN; //////////////////////////////////////////////////////////////////////////
| 1808 | // |
| 1809 | /////////////////////////////////////////////////////////////////////////////// |
| 1810 | void |
| 1811 | HttpTransact::PPDNSLookup(State *s) |
| 1812 | { |
| 1813 | TxnDbg(dbg_ctl_http_trans, "Entering HttpTransact::PPDNSLookup"); |
| 1814 | |
| 1815 | ink_assert(s->dns_info.looking_up == ResolveInfo::PARENT_PROXY); |
| 1816 | if (!s->dns_info.resolved_p) { |
| 1817 | // Mark parent as down due to resolving failure |
| 1818 | markParentDown(s); |
| 1819 | // DNS lookup of parent failed, find next parent or o.s. |
| 1820 | if (find_server_and_update_current_info(s) == ResolveInfo::HOST_NONE) { |
| 1821 | if (is_cache_hit(s->cache_lookup_result) && is_stale_cache_response_returnable(s)) { |
| 1822 | s->source = SOURCE_CACHE; |
| 1823 | TxnDbg(dbg_ctl_http_trans, "All parents are down, serving stale doc to client"); |
| 1824 | build_response_from_cache(s, HTTP_WARNING_CODE_REVALIDATION_FAILED); |
| 1825 | return; |
| 1826 | } |
| 1827 | ink_assert(s->current.request_to == ResolveInfo::HOST_NONE); |
| 1828 | handle_parent_down(s); |
| 1829 | return; |
| 1830 | } |
| 1831 | |
| 1832 | if (!s->current.server->dst_addr.isValid()) { |
| 1833 | if (s->current.request_to == ResolveInfo::PARENT_PROXY) { |
| 1834 | TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookupAPICall); |
| 1835 | } else if (s->parent_result.result == PARENT_DIRECT && s->txn_conf->no_dns_forward_to_parent != 1) { |
| 1836 | // We ran out of parents but parent configuration allows us to go to Origin Server directly |
| 1837 | CallOSDNSLookup(s); |
| 1838 | return; |
| 1839 | } else { |
| 1840 | // We could be out of parents here if all the parents failed DNS lookup |
| 1841 | ink_assert(s->current.request_to == ResolveInfo::HOST_NONE); |
| 1842 | handle_parent_down(s); |
| 1843 | } |
| 1844 | return; |
| 1845 | } |
| 1846 | } else { |
| 1847 | // lookup succeeded, open connection to p.p. |
| 1848 | ats_ip_copy(&s->parent_info.dst_addr, s->dns_info.addr); |
| 1849 | s->parent_info.dst_addr.network_order_port() = htons(s->parent_result.port); |
| 1850 | get_ka_info_from_host_db(s, &s->parent_info, &s->client_info, s->dns_info.active); |
| 1851 | |
| 1852 | ip_port_text_buffer addrbuf; |
| 1853 | TxnDbg(dbg_ctl_http_trans, "DNS lookup for successful IP: %s", |
| 1854 | ats_ip_nptop(&s->parent_info.dst_addr.sa, addrbuf, sizeof(addrbuf))); |
| 1855 | } |
| 1856 | |
| 1857 | // Since this function can be called several times while retrying |
| 1858 | // parents, check to see if we've already built our request |
| 1859 | if (!s->hdr_info.server_request.valid()) { |
| 1860 | build_request(s, &s->hdr_info.client_request, &s->hdr_info.server_request, s->current.server->http_version); |
| 1861 | // Take care of deferred (issue revalidate) work in building |
| 1862 | // the request |
| 1863 | if (s->pending_work != nullptr) { |
| 1864 | ink_assert(s->pending_work == issue_revalidate); |
| 1865 | (*s->pending_work)(s); |
| 1866 | s->pending_work = nullptr; |
| 1867 | } |
nothing calls this directly
no test coverage detected