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

Function ap_proxy_define_worker_ex

modules/proxy/proxy_util.c:1965–2191  ·  view source on GitHub ↗

* To create a worker from scratch first we define the * specifics of the worker; this is all local data. * We then allocate space for it if data needs to be * shared. This allows for dynamic addition during * config and runtime. */

Source from the content-addressed store, hash-verified

1963 * config and runtime.
1964 */
1965PROXY_DECLARE(char *) ap_proxy_define_worker_ex(apr_pool_t *p,
1966 proxy_worker **worker,
1967 proxy_balancer *balancer,
1968 proxy_server_conf *conf,
1969 const char *url,
1970 unsigned int mask)
1971{
1972 apr_status_t rv;
1973 proxy_worker_shared *wshared;
1974 const char *ptr = NULL, *sockpath = NULL, *pdollars = NULL;
1975 apr_port_t port_of_scheme;
1976 int address_not_reusable = 0;
1977 apr_uri_t uri;
1978
1979 /*
1980 * Look to see if we are using UDS:
1981 * require format: unix:/path/foo/bar.sock|http://ignored/path2/
1982 * This results in talking http to the socket at /path/foo/bar.sock
1983 */
1984 if (!ap_cstr_casecmpn(url, "unix:", 5)
1985 && (ptr = ap_strchr_c(url + 5, '|'))) {
1986 rv = apr_uri_parse(p, apr_pstrmemdup(p, url, ptr - url), &uri);
1987 if (rv == APR_SUCCESS) {
1988 sockpath = ap_runtime_dir_relative(p, uri.path);
1989 ptr++; /* so we get the scheme for the uds */
1990 }
1991 else {
1992 ptr = url;
1993 }
1994 }
1995 else {
1996 ptr = url;
1997 }
1998
1999 if (mask & AP_PROXY_WORKER_IS_MATCH) {
2000 /* apr_uri_parse() will accept the '$' sign anywhere in the URL but
2001 * in the :port part, and we don't want scheme://host:port$1$2/path
2002 * to fail (e.g. "ProxyPassMatch ^/(a|b)(/.*)? http://host:port$2").
2003 * So we trim all the $n from the :port and prepend them in uri.path
2004 * afterward for apr_uri_unparse() to restore the original URL below.
2005 * If a dollar substitution is found in the hostname[:port] part of
2006 * the URL, reusing address and connections in the same worker is not
2007 * possible (the current implementation of active connections cache
2008 * handles/assumes a single origin server:port per worker only), so
2009 * we set address_not_reusable here during parsing to take that into
2010 * account in the worker settings below.
2011 */
2012#define IS_REF(x) (x[0] == '$' && apr_isdigit(x[1]))
2013 const char *pos = ap_strstr_c(ptr, "://");
2014 if (pos) {
2015 pos += 3;
2016 while (*pos && *pos != ':' && *pos != '/') {
2017 if (*pos == '$') {
2018 address_not_reusable = 1;
2019 }
2020 pos++;
2021 }
2022 if (*pos == ':') {

Callers 5

add_passFunction · 0.85
set_proxy_paramFunction · 0.85
proxysectionFunction · 0.85
ap_proxy_define_workerFunction · 0.85

Calls 9

ap_cstr_casecmpnFunction · 0.85
ap_strchr_cFunction · 0.85
ap_runtime_dir_relativeFunction · 0.85
ap_strstr_cFunction · 0.85
ap_str_tolowerFunction · 0.85
ap_proxy_port_of_schemeFunction · 0.85
ap_mallocFunction · 0.85
ap_proxy_hashfuncFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected