MCPcopy Create free account
hub / github.com/apache/httpd / worker_address_resolve

Function worker_address_resolve

modules/proxy/proxy_util.c:2891–2948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2889}
2890
2891static apr_status_t worker_address_resolve(proxy_worker *worker,
2892 apr_sockaddr_t **paddr,
2893 const char *hostname,
2894 apr_port_t hostport,
2895 const char *proxy_function,
2896 request_rec *r, server_rec *s)
2897{
2898 apr_status_t rv;
2899 apr_pool_t *pool = NULL;
2900
2901 apr_pool_create(&pool, worker->cp->dns_pool);
2902 rv = apr_sockaddr_info_get(paddr, hostname, APR_UNSPEC,
2903 hostport, 0, pool);
2904 if (rv != APR_SUCCESS) {
2905 if (r && !s) {
2906 proxyerror_core(r, HTTP_INTERNAL_SERVER_ERROR,
2907 apr_pstrcat(pool,
2908 "DNS lookup failure for: ",
2909 hostname, NULL),
2910 rv);
2911 }
2912 else if (r) {
2913 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(10477)
2914 "%s: resolving worker %s address",
2915 proxy_function, hostname);
2916 }
2917 else {
2918 ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(10478)
2919 "%s: resolving worker %s address",
2920 proxy_function, hostname);
2921 }
2922 apr_pool_destroy(pool);
2923 return rv;
2924 }
2925
2926 if (r ? APLOGrdebug(r) : APLOGdebug(s)) {
2927 char *addrs = NULL;
2928 apr_sockaddr_t *addr = *paddr;
2929 for (; addr; addr = addr->next) {
2930 addrs = apr_psprintf(pool, "%s%s%pI",
2931 addrs ? addrs : "",
2932 addrs ? ", " : "",
2933 addr);
2934 }
2935 if (r) {
2936 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(10479)
2937 "%s: %s resolved to %s",
2938 proxy_function, hostname, addrs);
2939 }
2940 else {
2941 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(10480)
2942 "%s: %s resolved to %s",
2943 proxy_function, hostname, addrs);
2944 }
2945 }
2946
2947 return APR_SUCCESS;
2948}

Callers 1

Calls 2

proxyerror_coreFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected