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

Function ap_proxy_sync_balancer

modules/proxy/proxy_util.c:4358–4441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4356}
4357
4358PROXY_DECLARE(apr_status_t) ap_proxy_sync_balancer(proxy_balancer *b, server_rec *s,
4359 proxy_server_conf *conf)
4360{
4361 proxy_worker **workers;
4362 int i;
4363 int index;
4364 proxy_worker_shared *shm;
4365 proxy_balancer_method *lbmethod;
4366 ap_slotmem_provider_t *storage = b->storage;
4367
4368 if (b->s->wupdated <= b->wupdated)
4369 return APR_SUCCESS;
4370 /* balancer sync */
4371 lbmethod = ap_lookup_provider(PROXY_LBMETHOD, b->s->lbpname, "0");
4372 if (lbmethod) {
4373 b->lbmethod = lbmethod;
4374 } else {
4375 ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, APLOGNO(02433)
4376 "Cannot find LB Method: %s", b->s->lbpname);
4377 return APR_EINVAL;
4378 }
4379
4380 /* worker sync */
4381
4382 /*
4383 * Look thru the list of workers in shm
4384 * and see which one(s) we are lacking...
4385 * again, the cast to unsigned int is safe
4386 * since our upper limit is always max_workers
4387 * which is int.
4388 */
4389 for (index = 0; index < b->max_workers; index++) {
4390 int found;
4391 apr_status_t rv;
4392 if ((rv = storage->dptr(b->wslot, (unsigned int)index, (void *)&shm)) != APR_SUCCESS) {
4393 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(00965) "worker slotmem_dptr failed");
4394 return APR_EGENERAL;
4395 }
4396 /* account for possible "holes" in the slotmem
4397 * (eg: slots 0-2 are used, but 3 isn't, but 4-5 is)
4398 */
4399 if (!shm->hash.def || !shm->hash.fnv)
4400 continue;
4401 found = 0;
4402 workers = (proxy_worker **)b->workers->elts;
4403 for (i = 0; i < b->workers->nelts; i++, workers++) {
4404 proxy_worker *worker = *workers;
4405 if (worker->hash.def == shm->hash.def && worker->hash.fnv == shm->hash.fnv) {
4406 found = 1;
4407 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02402)
4408 "re-grabbing shm[%d] (0x%pp) for worker: %s", i, (void *)shm,
4409 ap_proxy_worker_name(conf->pool, worker));
4410 break;
4411 }
4412 }
4413 if (!found) {
4414 proxy_worker **runtime;
4415 /* XXX: a thread mutex is maybe enough here */

Callers 5

mod_proxy.hFile · 0.85
balancer_post_configFunction · 0.85
balancer_handlerFunction · 0.85
hc_watchdog_callbackFunction · 0.85

Calls 4

ap_lookup_providerFunction · 0.85
ap_proxy_worker_nameFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected