module AP_MODULE_DECLARE_DATA lbmethod_bybusyness_module;
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+ proxy_worker *worker, server_rec *s) = NULL;
+
static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
request_rec *r)
{
int total_factor = 0;
+ if (!ap_proxy_retry_worker_fn) {
+ ap_proxy_retry_worker_fn =
+ APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+ if (!ap_proxy_retry_worker_fn) {
+ /* can only happen if mod_proxy isn't loaded */
+ return NULL;
+ }
+ }
+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: Entering bybusyness for BALANCER (%s)",
balancer->s->name);
* The worker might still be unusable, but we try
* anyway.
*/
- if (!PROXY_WORKER_IS_USABLE(*worker))
- ap_proxy_retry_worker("BALANCER", *worker, r->server);
+ if (!PROXY_WORKER_IS_USABLE(*worker)) {
+ ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
+ }
/* Take into calculation only the workers that are
* not in error state or not disabled.
module AP_MODULE_DECLARE_DATA lbmethod_byrequests_module;
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+ proxy_worker *worker, server_rec *s) = NULL;
+
/*
* The idea behind the find_best_byrequests scheduler is the following:
*
int checking_standby;
int checked_standby;
+ if (!ap_proxy_retry_worker_fn) {
+ ap_proxy_retry_worker_fn =
+ APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+ if (!ap_proxy_retry_worker_fn) {
+ /* can only happen if mod_proxy isn't loaded */
+ return NULL;
+ }
+ }
+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: Entering byrequests for BALANCER (%s)",
balancer->s->name);
* anyway.
*/
if (!PROXY_WORKER_IS_USABLE(*worker))
- ap_proxy_retry_worker("BALANCER", *worker, r->server);
+ ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
/* Take into calculation only the workers that are
* not in error state or not disabled.
*/
module AP_MODULE_DECLARE_DATA lbmethod_bytraffic_module;
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+ proxy_worker *worker, server_rec *s) = NULL;
+
/*
* The idea behind the find_best_bytraffic scheduler is the following:
*
int checking_standby;
int checked_standby;
+ if (!ap_proxy_retry_worker_fn) {
+ ap_proxy_retry_worker_fn =
+ APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+ if (!ap_proxy_retry_worker_fn) {
+ /* can only happen if mod_proxy isn't loaded */
+ return NULL;
+ }
+ }
+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: Entering bytraffic for BALANCER (%s)",
balancer->s->name);
* anyway.
*/
if (!PROXY_WORKER_IS_USABLE(*worker))
- ap_proxy_retry_worker("BALANCER", *worker, r->server);
+ ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
/* Take into calculation only the workers that are
* not in error state or not disabled.
*/
module AP_MODULE_DECLARE_DATA lbmethod_heartbeat_module;
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+ proxy_worker *worker, server_rec *s) = NULL;
+
static const ap_slotmem_provider_t *storage = NULL;
static ap_slotmem_instance_t *hm_serversmem = NULL;
ap_get_module_config(r->server->module_config,
&lbmethod_heartbeat_module);
+ if (!ap_proxy_retry_worker_fn) {
+ ap_proxy_retry_worker_fn =
+ APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+ if (!ap_proxy_retry_worker_fn) {
+ /* can only happen if mod_proxy isn't loaded */
+ return NULL;
+ }
+ }
+
apr_pool_create(&tpool, r->pool);
servers = apr_hash_make(tpool);
}
if (!PROXY_WORKER_IS_USABLE(*worker)) {
- ap_proxy_retry_worker("BALANCER", *worker, r->server);
+ ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
}
if (PROXY_WORKER_IS_USABLE(*worker)) {
#include "apr_optional.h"
#include "scoreboard.h"
#include "mod_status.h"
+#include "proxy_util.h"
#if (MODULE_MAGIC_NUMBER_MAJOR > 20020903)
#include "mod_ssl.h"
/* child init handling */
ap_hook_child_init(child_init, aszPred, NULL, APR_HOOK_MIDDLE);
+ /* register optional functions within proxy_util.c */
+ proxy_util_register_hooks(p);
}
AP_DECLARE_MODULE(proxy) =
*/
#include "apr_hooks.h"
+#include "apr_optional.h"
#include "apr.h"
#include "apr_lib.h"
#include "apr_strings.h"
* @note The error status of the worker will cleared if the retry interval has
* elapsed since the last error.
*/
-PROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
- proxy_worker *worker,
- server_rec *s);
+APR_DECLARE_OPTIONAL_FN(int, ap_proxy_retry_worker,
+ (const char *proxy_function, proxy_worker *worker, server_rec *s));
/**
* Acquire a connection from worker connection pool
module AP_MODULE_DECLARE_DATA proxy_balancer_module;
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+ proxy_worker *worker, server_rec *s) = NULL;
+
/*
* Register our mutex type before the config is read so we
* can adjust the mutex settings using the Mutex directive.
* The worker might still be unusable, but we try
* anyway.
*/
- ap_proxy_retry_worker("BALANCER", worker, r->server);
+ ap_proxy_retry_worker_fn("BALANCER", worker, r->server);
if (PROXY_WORKER_IS_USABLE(worker)) {
return worker;
} else {
* The worker might still be unusable, but we try
* anyway.
*/
- ap_proxy_retry_worker("BALANCER", rworker, r->server);
+ ap_proxy_retry_worker_fn("BALANCER", rworker, r->server);
}
if (rworker && PROXY_WORKER_IS_USABLE(rworker))
return rworker;
}
else {
/* Try if we can recover */
- ap_proxy_retry_worker("BALANCER", *worker, s);
+ ap_proxy_retry_worker_fn("BALANCER", *worker, s);
if (!((*worker)->s->status & PROXY_WORKER_IN_ERROR)) {
ok = 1;
break;
/* balancer_post_config() will be called twice during startup. So, don't
* set up the static data the 1st time through. */
- if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
return OK;
+ }
+
+ if (!ap_proxy_retry_worker_fn) {
+ ap_proxy_retry_worker_fn =
+ APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+ if (!ap_proxy_retry_worker_fn) {
+ ap_log_error(
+ APLOG_MARK, APLOG_EMERG, 0, s, "mod_proxy must be loaded for mod_proxy_balancer");
+ return !OK;
+ }
+ }
/*
* Get slotmem setups
#include "scoreboard.h"
#include "apr_version.h"
#include "apr_hash.h"
+#include "proxy_util.h"
#if APR_HAVE_UNISTD_H
#include <unistd.h> /* for getpid() */
return rv;
}
-PROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
- proxy_worker *worker,
- server_rec *s)
+static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worker,
+ server_rec *s)
{
if (worker->s->status & PROXY_WORKER_IN_ERROR) {
if (apr_time_now() > worker->s->error_time + worker->s->retry) {
return APR_SUCCESS;
}
+void proxy_util_register_hooks(apr_pool_t *p)
+{
+ APR_REGISTER_OPTIONAL_FN(ap_proxy_retry_worker);
+}
--- /dev/null
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PROXY_UTIL_H_
+#define PROXY_UTIL_H_
+
+/**
+ * @file proxy_util.h
+ * @brief Internal interfaces private to mod_proxy.
+ *
+ * @defgroup MOD_PROXY_PRIVATE Private
+ * @ingroup MOD_PROXY
+ * @{
+ */
+
+/**
+ * Register optional functions declared within proxy_util.c.
+ */
+void proxy_util_register_hooks(apr_pool_t *p);
+
+/** @} */
+
+#endif /* PROXY_UTIL_H_ */