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

Function ap_proxy_determine_address

modules/proxy/proxy_util.c:2972–3235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2970}
2971
2972PROXY_DECLARE(apr_status_t) ap_proxy_determine_address(const char *proxy_function,
2973 proxy_conn_rec *conn,
2974 const char *hostname,
2975 apr_port_t hostport,
2976 unsigned int flags,
2977 request_rec *r,
2978 server_rec *s)
2979{
2980 proxy_worker *worker = conn->worker;
2981 apr_status_t rv;
2982
2983 /*
2984 * Worker can have the single constant backend adress.
2985 * The single DNS lookup is used once per worker.
2986 * If dynamic change is needed then set the addr to NULL
2987 * inside dynamic config to force the lookup.
2988 * The worker's addressTTL parameter may also be configured
2989 * to perform the DNS lookups only when the TTL expires,
2990 * or each time if that TTL is zero.
2991 */
2992 if (!worker->s->is_address_reusable) {
2993 conn->hostname = apr_pstrdup(conn->pool, hostname);
2994 conn->port = hostport;
2995
2996 rv = apr_sockaddr_info_get(&conn->addr, hostname, APR_UNSPEC,
2997 hostport, 0, conn->pool);
2998 if (rv != APR_SUCCESS) {
2999 if (r && !s) {
3000 proxyerror_core(r, HTTP_INTERNAL_SERVER_ERROR,
3001 apr_pstrcat(r->pool, "DNS lookup failure for: ",
3002 hostname, NULL), rv);
3003 }
3004 else if (r) {
3005 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(10475)
3006 "%s: resolving backend %s address",
3007 proxy_function, hostname);
3008 }
3009 else {
3010 ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(10476)
3011 "%s: resolving backend %s address",
3012 proxy_function, hostname);
3013 }
3014 return rv;
3015 }
3016 }
3017 else {
3018 apr_sockaddr_t *addr = NULL;
3019 proxy_address *address = NULL;
3020 apr_int32_t ttl = worker->s->address_ttl;
3021 apr_uint32_t now = 0;
3022
3023 if (flags & PROXY_DETERMINE_ADDRESS_CHECK) {
3024 /* The caller wants to check if the address changed, return
3025 * APR_EEXIST if not, otherwise fall through to update the
3026 * worker's for everyone to switch.
3027 */
3028 if (!conn->addr) {
3029 /* Need something to compare with */

Callers 4

hc_determine_connectionFunction · 0.85
proxy_ftp_handlerFunction · 0.85
ap_proxy_connect_backendFunction · 0.85

Calls 8

proxyerror_coreFunction · 0.85
worker_address_resolveFunction · 0.85
proxy_addrs_equalFunction · 0.85
worker_address_getFunction · 0.85
worker_address_setFunction · 0.85
proxy_address_incFunction · 0.85
conn_cleanupFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected