Find the worker that has the 'route' defined */
| 199 | /* Find the worker that has the 'route' defined |
| 200 | */ |
| 201 | static proxy_worker *find_route_worker(proxy_balancer *balancer, |
| 202 | const char *route, request_rec *r, |
| 203 | int recursion) |
| 204 | { |
| 205 | int i; |
| 206 | int checking_standby; |
| 207 | int checked_standby; |
| 208 | |
| 209 | proxy_worker **workers; |
| 210 | |
| 211 | checking_standby = checked_standby = 0; |
| 212 | while (!checked_standby) { |
| 213 | workers = (proxy_worker **)balancer->workers->elts; |
| 214 | for (i = 0; i < balancer->workers->nelts; i++, workers++) { |
| 215 | proxy_worker *worker = *workers; |
| 216 | if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) ) |
| 217 | continue; |
| 218 | if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) { |
| 219 | if (PROXY_WORKER_IS_USABLE(worker)) { |
| 220 | return worker; |
| 221 | } else { |
| 222 | /* |
| 223 | * If the worker is in error state run |
| 224 | * retry on that worker. It will be marked as |
| 225 | * operational if the retry timeout is elapsed. |
| 226 | * The worker might still be unusable, but we try |
| 227 | * anyway. |
| 228 | */ |
| 229 | ap_proxy_retry_worker_fn("BALANCER", worker, r->server); |
| 230 | if (PROXY_WORKER_IS_USABLE(worker)) { |
| 231 | return worker; |
| 232 | } else { |
| 233 | /* |
| 234 | * We have a worker that is unusable. |
| 235 | * It can be in error or disabled, but in case |
| 236 | * it has a redirection set use that redirection worker. |
| 237 | * This enables to safely remove the member from the |
| 238 | * balancer. Of course you will need some kind of |
| 239 | * session replication between those two remote. |
| 240 | * Also check that we haven't gone thru all the |
| 241 | * balancer members by means of redirects. |
| 242 | * This should avoid redirect cycles. |
| 243 | */ |
| 244 | if ((*worker->s->redirect) |
| 245 | && (recursion < balancer->workers->nelts)) { |
| 246 | proxy_worker *rworker = NULL; |
| 247 | rworker = find_route_worker(balancer, worker->s->redirect, |
| 248 | r, recursion + 1); |
| 249 | /* Check if the redirect worker is usable */ |
| 250 | if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) { |
| 251 | /* |
| 252 | * If the worker is in error state run |
| 253 | * retry on that worker. It will be marked as |
| 254 | * operational if the retry timeout is elapsed. |
| 255 | * The worker might still be unusable, but we try |
| 256 | * anyway. |
| 257 | */ |
| 258 | ap_proxy_retry_worker_fn("BALANCER", rworker, r->server); |
no outgoing calls
no test coverage detected