Lines Matching defs:worker

872          * find the particulars of the actual worker which may
879 proxy_worker **worker = (proxy_worker **)balancer->workers->elts;
893 l2 = strlen((*worker)->s->name);
896 if ((*worker)->s->name[l2 - 1] == '/')
899 && strncasecmp((*worker)->s->name, url, l2) == 0
906 else if (l1 >= l2 && strncasecmp((*worker)->s->name, url, l2) == 0) {
915 worker++;
1273 * mutex and then attach to the shared worker shm
1318 proxy_worker *worker = (proxy_worker *)theworker;
1319 if (worker->cp->res) {
1320 worker->cp->pool = NULL;
1325 static void init_conn_pool(apr_pool_t *p, proxy_worker *worker)
1333 * Once the worker is added it is never removed but
1339 * Alloc from the same pool as worker.
1340 * proxy_conn_pool is permanently attached to the worker.
1344 worker->cp = cp;
1349 proxy_worker *worker = conn->worker;
1351 return ! (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse);
1357 proxy_worker *worker = conn->worker;
1360 * If the connection pool is NULL the worker
1363 if (!worker->cp) {
1375 "Pooled connection 0x%pp for worker %s has been"
1377 ap_proxy_worker_name(conn->pool, worker));
1387 conn->worker = worker;
1392 if (worker->s->hmax && worker->cp->res) {
1394 apr_reslist_release(worker->cp->res, (void *)conn);
1398 worker->cp->conn = conn;
1455 proxy_worker *worker = (proxy_worker *)params;
1477 conn->worker = worker;
1491 if (conn->worker->cp->pool) {
1503 proxy_worker *worker)
1505 if (!(*worker->s->uds_path) || !p) {
1507 return worker->s->name;
1509 return apr_pstrcat(p, "unix:", worker->s->uds_path, "|", worker->s->name, NULL);
1547 /* We got all the way through the worker path without a difference */
1556 proxy_worker *worker;
1600 * Do a "longest match" on the worker name to find the worker that
1603 * scheme://hostname[:port] matches between worker and url.
1609 worker = *workers;
1610 if ( ((worker_name_length = strlen(worker->s->name)) <= url_length)
1613 && (worker->s->is_name_matchable
1614 || strncmp(url_copy, worker->s->name,
1616 && (!worker->s->is_name_matchable
1618 worker->s->name) == 0) ) {
1619 max_worker = worker;
1624 worker = (proxy_worker *)conf->workers->elts;
1625 for (i = 0; i < conf->workers->nelts; i++, worker++) {
1626 if ( ((worker_name_length = strlen(worker->s->name)) <= url_length)
1629 && (worker->s->is_name_matchable
1630 || strncmp(url_copy, worker->s->name,
1632 && (!worker->s->is_name_matchable
1634 worker->s->name) == 0) ) {
1635 max_worker = worker;
1646 * To create a worker from scratch first we define the
1647 * specifics of the worker; this is all local data.
1653 proxy_worker **worker,
1704 * own; ie: the generic reverse-proxy or a worker
1709 * in which case the worker goes in the conf slot.
1715 *worker = *runtime = apr_palloc(p, sizeof(proxy_worker)); /* right to left baby */
1720 *worker = apr_array_push(conf->workers);
1723 *worker = apr_palloc(p, sizeof(proxy_worker));
1726 memset(*worker, 0, sizeof(proxy_worker));
1727 /* right here we just want to tuck away the worker info.
1743 "Alert! worker name (%s) too long; truncated to: %s", ptr, wshared->name);
1746 return apr_psprintf(p, "worker scheme (%s) too long", uri.scheme);
1749 return apr_psprintf(p, "worker hostname (%s) too long", uri.hostname);
1763 return apr_psprintf(p, "worker uds path (%s) too long", sockpath);
1774 (*worker)->hash = wshared->hash;
1775 (*worker)->context = NULL;
1776 (*worker)->cp = NULL;
1777 (*worker)->balancer = balancer;
1778 (*worker)->s = wshared;
1784 proxy_worker **worker,
1792 err = ap_proxy_define_worker(p, worker, balancer, conf, url, do_malloc);
1797 (*worker)->s->is_name_matchable = 1;
1802 * Create an already defined worker and free up memory
1804 PROXY_DECLARE(apr_status_t) ap_proxy_share_worker(proxy_worker *worker, proxy_worker_shared *shm,
1808 if (!shm || !worker->s)
1811 if ((worker->s->hash.def != shm->hash.def) ||
1812 (worker->s->hash.fnv != shm->hash.fnv)) {
1813 memcpy(shm, worker->s, sizeof(proxy_worker_shared));
1814 if (worker->s->was_malloced)
1815 free(worker->s); /* was malloced in ap_proxy_define_worker */
1819 worker->s = shm;
1820 worker->s->index = i;
1825 "%s shm[%d] (0x%pp) for worker: %s", action, i, (void *)shm,
1826 ap_proxy_worker_name(pool, worker));
1834 PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s, apr_pool_t *p)
1839 if (worker->s->status & PROXY_WORKER_INITIALIZED) {
1840 /* The worker is already initialized */
1842 "worker %s shared already initialized",
1843 ap_proxy_worker_name(p, worker));
1847 "initializing worker %s shared",
1848 ap_proxy_worker_name(p, worker));
1850 if (!worker->s->retry_set) {
1851 worker->s->retry = apr_time_from_sec(PROXY_WORKER_DEFAULT_RETRY);
1854 if (worker->s->disablereuse) {
1855 worker->s->is_address_reusable = 0;
1858 worker->s->is_address_reusable = 1;
1864 if (worker->s->hmax == 0 || worker->s->hmax > mpm_threads) {
1865 worker->s->hmax = mpm_threads;
1867 if (worker->s->smax == -1 || worker->s->smax > worker->s->hmax) {
1868 worker->s->smax = worker->s->hmax;
1871 if (worker->s->min > worker->s->smax) {
1872 worker->s->min = worker->s->smax;
1877 worker->s->min = worker->s->smax = worker->s->hmax = 0;
1882 if (worker->local_status & PROXY_WORKER_INITIALIZED) {
1884 "worker %s local already initialized",
1885 ap_proxy_worker_name(p, worker));
1889 "initializing worker %s local",
1890 ap_proxy_worker_name(p, worker));
1892 /* Now init local worker data */
1893 if (worker->tmutex == NULL) {
1894 rv = apr_thread_mutex_create(&(worker->tmutex), APR_THREAD_MUTEX_DEFAULT, p);
1897 "can not create worker thread mutex");
1902 if (worker->cp == NULL)
1903 init_conn_pool(p, worker);
1904 if (worker->cp == NULL) {
1911 if (worker->s->hmax) {
1912 rv = apr_reslist_create(&(worker->cp->res),
1913 worker->s->min, worker->s->smax,
1914 worker->s->hmax, worker->s->ttl,
1916 worker, worker->cp->pool);
1918 apr_pool_cleanup_register(worker->cp->pool, (void *)worker,
1924 getpid(), worker->s->hostname, worker->s->min,
1925 worker->s->hmax, worker->s->smax);
1928 if (rv == APR_SUCCESS && worker->s->acquire_set) {
1929 apr_reslist_timeout_set(worker->cp->res, worker->s->acquire);
1936 rv = connection_constructor(&conn, worker, worker->cp->pool);
1937 worker->cp->conn = conn;
1940 "initialized single connection worker in child %" APR_PID_T_FMT " for (%s)",
1941 getpid(), worker->s->hostname);
1947 worker->s->status |= (PROXY_WORKER_INITIALIZED);
1948 worker->local_status |= (PROXY_WORKER_INITIALIZED);
1953 static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worker,
1956 if (worker->s->status & PROXY_WORKER_IN_ERROR) {
1957 if ((worker->s->status & PROXY_WORKER_IGNORE_ERRORS)
1958 || apr_time_now() > worker->s->error_time + worker->s->retry) {
1959 ++worker->s->retries;
1960 worker->s->status &= ~PROXY_WORKER_IN_ERROR;
1962 "%s: worker for (%s) has been marked for retry",
1963 proxy_function, worker->s->hostname);
1968 "%s: too soon to retry worker for (%s)",
1969 proxy_function, worker->s->hostname);
2012 PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
2019 access_status = proxy_run_pre_request(worker, balancer, r, conf, url);
2021 *worker = ap_proxy_get_worker(r->pool, NULL, conf, *url);
2022 if (*worker) {
2024 "%s: found worker %s for %s",
2025 (*worker)->s->scheme, (*worker)->s->name, *url);
2033 "*: found forward proxy worker for %s", *url);
2035 *worker = conf->forward;
2038 * The forward worker does not keep connections alive, so
2048 "*: using default reverse proxy worker for %s (no keepalive)", *url);
2050 *worker = conf->reverse;
2053 * The reverse worker does not keep connections alive, so
2071 PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
2078 access_status = proxy_run_post_request(worker, balancer, r, conf);
2081 /* TODO: recycle direct worker */
2172 proxy_worker *worker,
2177 if (!PROXY_WORKER_IS_USABLE(worker)) {
2178 /* Retry the worker */
2179 ap_proxy_retry_worker(proxy_function, worker, s);
2181 if (!PROXY_WORKER_IS_USABLE(worker)) {
2184 proxy_function, worker->s->hostname);
2189 if (worker->s->hmax && worker->cp->res) {
2190 rv = apr_reslist_acquire(worker->cp->res, (void **)conn);
2194 if (!worker->cp->conn) {
2195 connection_constructor((void **)conn, worker, worker->cp->pool);
2198 *conn = worker->cp->conn;
2199 worker->cp->conn = NULL;
2207 proxy_function, worker->s->hostname);
2212 proxy_function, worker->s->hostname);
2214 (*conn)->worker = worker;
2227 proxy_function, conn->worker->s->hostname);
2236 proxy_worker *worker,
2291 * spilling the cached addr from the worker.
2293 uds_path = (*worker->s->uds_path ? worker->s->uds_path : apr_table_get(r->notes, "uds_path"));
2296 /* use (*conn)->pool instead of worker->cp->pool to match lifetime */
2324 int will_reuse = worker->s->is_address_reusable && !worker->s->disablereuse;
2365 * Otherwise we will look it up once for the worker.
2377 * Looking up the backend address for the worker only makes sense if
2380 if (!worker->cp->addr) {
2381 if ((err = PROXY_THREAD_LOCK(worker)) != APR_SUCCESS) {
2388 * The single DNS lookup is used once per worker.
2392 err = apr_sockaddr_info_get(&(worker->cp->addr),
2395 worker->cp->pool);
2396 conn->addr = worker->cp->addr;
2397 if ((uerr = PROXY_THREAD_UNLOCK(worker)) != APR_SUCCESS) {
2402 conn->addr = worker->cp->addr;
2697 proxy_worker *worker,
2731 worker->s->hostname);
2744 worker->s->hostname);
2753 worker->s->hostname);
2767 worker->s->hostname);
2778 if (worker->s->recv_buffer_size > 0 &&
2780 worker->s->recv_buffer_size))) {
2794 if (worker->s->conn_timeout_set) {
2795 apr_socket_timeout_set(newsock, worker->s->conn_timeout);
2797 else if (worker->s->timeout_set) {
2798 apr_socket_timeout_set(newsock, worker->s->timeout);
2807 if (worker->s->keepalive) {
2817 proxy_function, backend_addr->family, worker->s->hostname);
2842 worker->s->hostname);
2851 worker->s->hostname);
2855 if (worker->s->timeout_set) {
2856 apr_socket_timeout_set(newsock, worker->s->timeout);
2885 backend_addr, worker->s->hostname);
2894 if (PROXY_WORKER_IS_USABLE(worker)) {
2896 * Put the entire worker to error state if
2899 * no further connections to the worker could be made
2902 if (!(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) {
2903 worker->s->error_time = apr_time_now();
2904 worker->s->status |= PROXY_WORKER_IN_ERROR;
2906 "ap_proxy_connect_backend disabling worker for (%s) for %"
2908 worker->s->hostname, apr_time_sec(worker->s->retry));
2912 if (worker->s->retries) {
2914 * A worker came back. So here is where we need to
2919 worker->s->error_time = 0;
2920 worker->s->retries = 0;
2926 * The worker is in error likely done by a different thread / process
2928 * not continue with a connection via this worker even if we got one.
3167 /* worker sync */
3180 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(00965) "worker slotmem_dptr failed");
3191 proxy_worker *worker = *workers;
3192 if (worker->hash.def == shm->hash.def && worker->hash.fnv == shm->hash.fnv) {
3195 "re-grabbing shm[%d] (0x%pp) for worker: %s", i, (void *)shm,
3196 ap_proxy_worker_name(conf->pool, worker));
3214 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(00966) "Cannot init worker");
3218 "grabbing shm[%d] (0x%pp) for worker: %s", i, (void *)shm,
3233 proxy_worker *worker,
3243 if ((worker->s->hash.def == shm->hash.def) &&
3244 (worker->s->hash.fnv == shm->hash.fnv)) {
3334 proxy_worker *worker,
3359 do_100_continue = (worker->s->ping_timeout_set
3360 && (worker->s->ping_timeout >= 0)
3626 p_conn->worker->s->transferred += transferred;