mod_lbmethod_bybusyness.c revision 2c4ed36c350564e8bfb68e9d9ba58fe77b9bf3c0
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim/* Licensed to the Apache Software Foundation (ASF) under one or more
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * contributor license agreements. See the NOTICE file distributed with
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * this work for additional information regarding copyright ownership.
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * The ASF licenses this file to You under the Apache License, Version 2.0
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * (the "License"); you may not use this file except in compliance with
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * the License. You may obtain a copy of the License at
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * Unless required by applicable law or agreed to in writing, software
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * distributed under the License is distributed on an "AS IS" BASIS,
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * See the License for the specific language governing permissions and
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * limitations under the License.
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jimmodule AP_MODULE_DECLARE_DATA lbmethod_bybusyness_module;
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jimstatic proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim "proxy: Entering bybusyness for BALANCER (%s)",
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim /* First try to see if we have available candidate */
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim for (i = 0; i < balancer->workers->nelts; i++, worker++) {
834fc281be8e0f7f2614961f12d8bbf603382a17jfclere if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(*worker) : PROXY_WORKER_IS_STANDBY(*worker)) )
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim /* If the worker is in error state run
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * retry on that worker. It will be marked as
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * operational if the retry timeout is elapsed.
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * The worker might still be unusable, but we try
834fc281be8e0f7f2614961f12d8bbf603382a17jfclere ap_proxy_retry_worker("BALANCER", *worker, r->server);
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim /* Take into calculation only the workers that are
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim * not in error state or not disabled.
834fc281be8e0f7f2614961f12d8bbf603382a17jfclere || ((*worker)->s->busy == mycandidate->s->busy && (*worker)->s->lbstatus > mycandidate->s->lbstatus))
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim "proxy: bybusyness selected worker \"%s\" : busy %" APR_SIZE_T_FMT " : lbstatus %d",
23a31b10f869a72c9197b5f153f4f3e1a4c68f28jim mycandidate->s->name, mycandidate->s->busy, mycandidate->s->lbstatus);
2c4ed36c350564e8bfb68e9d9ba58fe77b9bf3c0jim/* assumed to be mutex protected by caller */
6bed231822ad2aaba16de74c4c01023e5982a5e2jfclerestatic apr_status_t reset(proxy_balancer *balancer, server_rec *s) {
2c4ed36c350564e8bfb68e9d9ba58fe77b9bf3c0jim for (i = 0; i < balancer->workers->nelts; i++, worker++) {
6bed231822ad2aaba16de74c4c01023e5982a5e2jfclerestatic apr_status_t age(proxy_balancer *balancer, server_rec *s) {
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim "bybusyness",
dfcadcd3e6bbdee594540b8f8e4e50586a2e3219jim ap_register_provider(p, PROXY_LBMETHOD, "bybusyness", "0", &bybusyness);