summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Frederic Clere <jfclere@apache.org>2006-07-28 23:37:15 +0000
committerJean-Frederic Clere <jfclere@apache.org>2006-07-28 23:37:15 +0000
commit900139a1504fe337dfc67a4a3cf286ef6cd618d0 (patch)
tree383be120dd605d6e6af86adf9aba82812994098f
parentd0e5132941f93827c7034fd96ae4dd49ca77c705 (diff)
downloadhttpd-900139a1504fe337dfc67a4a3cf286ef6cd618d0.tar.gz
Arrange the warning. Thanks Jim.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@426708 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--modules/mem/mod_sharedmem.c3
-rw-r--r--modules/mem/sharedmem_util.c6
-rw-r--r--modules/mem/sharedmem_util.h20
-rw-r--r--modules/proxy/health_checker_util.c50
-rw-r--r--modules/proxy/mod_proxy.h5
-rw-r--r--modules/proxy/mod_proxy_health_checker.c8
-rw-r--r--modules/proxy/mod_proxy_health_checker.h13
-rw-r--r--modules/proxy/proxy_util.c2
-rw-r--r--support/proxymonitor.c7
9 files changed, 81 insertions, 33 deletions
diff --git a/modules/mem/mod_sharedmem.c b/modules/mem/mod_sharedmem.c
index 2b55118f02..a41d62656d 100644
--- a/modules/mem/mod_sharedmem.c
+++ b/modules/mem/mod_sharedmem.c
@@ -28,6 +28,7 @@
#include "http_log.h"
#include "slotmem.h"
+#include "sharedmem_util.h"
/* make sure the shared memory is cleaned */
static int initialize_cleanup(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
@@ -45,7 +46,7 @@ static int pre_config(apr_pool_t *p, apr_pool_t *plog,
static void ap_sharedmem_register_hook(apr_pool_t *p)
{
- slotmem_storage_method *storage = sharedmem_getstorage();
+ const slotmem_storage_method *storage = sharedmem_getstorage();
ap_register_provider(p, SLOTMEM_STORAGE, "shared", "0", storage);
ap_hook_post_config(initialize_cleanup, NULL, NULL, APR_HOOK_LAST);
ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE);
diff --git a/modules/mem/sharedmem_util.c b/modules/mem/sharedmem_util.c
index a330f1425f..2cf12817c8 100644
--- a/modules/mem/sharedmem_util.c
+++ b/modules/mem/sharedmem_util.c
@@ -20,6 +20,7 @@
#define CORE_PRIVATE
#include "apr.h"
+#include "apr_strings.h"
#include "apr_pools.h"
#include "apr_shm.h"
@@ -27,7 +28,8 @@
#include "http_config.h"
#include "http_log.h"
-#include "slotmem.h"
+#include "slotmem.h"
+#include "sharedmem_util.h"
/* The description of the slots to reuse the slotmem */
struct sharedslotdesc {
@@ -230,7 +232,7 @@ static const slotmem_storage_method storage = {
};
/* make the storage usuable from outside */
-slotmem_storage_method *sharedmem_getstorage()
+const slotmem_storage_method *sharedmem_getstorage()
{
return(&storage);
}
diff --git a/modules/mem/sharedmem_util.h b/modules/mem/sharedmem_util.h
new file mode 100644
index 0000000000..978a78f07e
--- /dev/null
+++ b/modules/mem/sharedmem_util.h
@@ -0,0 +1,20 @@
+/* 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.
+ */
+
+/* Memory handler for a shared memory divided in slot.
+ * This one uses shared memory.
+ */
+const slotmem_storage_method *sharedmem_getstorage();
diff --git a/modules/proxy/health_checker_util.c b/modules/proxy/health_checker_util.c
index b36cf6c471..932fee3280 100644
--- a/modules/proxy/health_checker_util.c
+++ b/modules/proxy/health_checker_util.c
@@ -130,7 +130,7 @@ static int getentrysize()
return sizeof(struct proxy_worker_conf);
}
/* copy the worker information in the shared area so the health-checker can extract the part it need */
-static apr_status_t add_entry(proxy_worker *worker, char *balancer_name, int id)
+static apr_status_t add_entry(proxy_worker *worker, const char *balancer_name, int id)
{
struct proxy_worker_conf *workerconf = NULL;
apr_status_t rv;
@@ -216,6 +216,7 @@ static apr_status_t set_health(int id, int value)
static apr_status_t get_entry(int id, proxy_worker **worker, char **balancer_name, apr_pool_t *pool)
{
struct proxy_worker_conf *workerconf = NULL;
+ char *ptr;
apr_status_t rv;
if (myscore == NULL)
@@ -227,7 +228,7 @@ static apr_status_t get_entry(int id, proxy_worker **worker, char **balancer_nam
/* allocate the data */
*worker = apr_pcalloc(pool, sizeof(proxy_worker));
if (workerconf->balancer_name)
- *balancer_name = apr_pcalloc(pool, strlen(workerconf->balancer_name));
+ *balancer_name = apr_pcalloc(pool, strlen(workerconf->balancer_name) + 1);
else
*balancer_name = NULL;
@@ -236,16 +237,31 @@ static apr_status_t get_entry(int id, proxy_worker **worker, char **balancer_nam
// XXX: what to do (* worker)->s = workerconf;
(* worker)->retry = workerconf->retry;
(* worker)->lbfactor = workerconf->lbfactor;
- if (workerconf->name)
- strcpy((* worker)->name, workerconf->name);
- if (workerconf->scheme)
- strcpy((* worker)->scheme, workerconf->scheme);
- if (workerconf->hostname)
- strcpy((* worker)->hostname, workerconf->hostname);
- if (workerconf->route)
- strcpy((* worker)->route, workerconf->route);
- if (workerconf->redirect)
- strcpy((* worker)->redirect, workerconf->redirect);
+ if (workerconf->name) {
+ ptr = apr_pcalloc(pool, strlen(workerconf->name) + 1);
+ strcpy(ptr, workerconf->name);
+ (* worker)->name = ptr;
+ }
+ if (workerconf->scheme) {
+ ptr = apr_pcalloc(pool, strlen(workerconf->scheme) + 1);
+ strcpy(ptr, workerconf->scheme);
+ (* worker)->scheme = ptr;
+ }
+ if (workerconf->hostname) {
+ ptr = apr_pcalloc(pool, strlen(workerconf->hostname) + 1);
+ strcpy(ptr, workerconf->hostname);
+ (* worker)->hostname = ptr;
+ }
+ if (workerconf->route) {
+ ptr = apr_pcalloc(pool, strlen(workerconf->route) + 1);
+ strcpy(ptr, workerconf->route);
+ (* worker)->route = ptr;
+ }
+ if (workerconf->redirect) {
+ ptr = apr_pcalloc(pool, strlen(workerconf->redirect) + 1);
+ strcpy(ptr, workerconf->redirect);
+ (* worker)->redirect = ptr;
+ }
(* worker)->status = workerconf->status;
(* worker)->port = workerconf->port;
(* worker)->min = workerconf->min;
@@ -272,7 +288,7 @@ static apr_status_t get_entryconf(int id, struct proxy_worker_conf **workerconf,
if (myscore == NULL)
return APR_ENOSHMAVAIL;
- rv = checkstorage->ap_slotmem_mem(myscore, id, workerconf);
+ rv = checkstorage->ap_slotmem_mem(myscore, id, (void **) workerconf);
if (rv != APR_SUCCESS)
return rv;
*balancer_name = (*workerconf)->balancer_name;
@@ -286,7 +302,7 @@ static apr_status_t check_entryhealth(int id, apr_pool_t *pool) {
if (myscore == NULL)
return APR_ENOSHMAVAIL;
- rv = checkstorage->ap_slotmem_mem(myscore, id, &workerconf);
+ rv = checkstorage->ap_slotmem_mem(myscore, id, (void **) &workerconf);
if (rv != APR_SUCCESS)
return rv;
/* If the error is not initialized to the worker to be removed keep it */
@@ -321,17 +337,17 @@ static const health_worker_method worker_storage = {
};
/* make the module usuable from outside */
-health_worker_method *health_checker_get_storage()
+const health_worker_method *health_checker_get_storage()
{
return(&worker_storage);
}
/* handle the slotmem storage */
-void health_checker_init_slotmem_storage(slotmem_storage_method * storage)
+void health_checker_init_slotmem_storage(const slotmem_storage_method * storage)
{
checkstorage = storage;
}
-slotmem_storage_method * health_checker_get_slotmem_storage()
+const slotmem_storage_method * health_checker_get_slotmem_storage()
{
return(checkstorage);
}
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
index 36c9ef8468..dcbec49ab4 100644
--- a/modules/proxy/mod_proxy.h
+++ b/modules/proxy/mod_proxy.h
@@ -446,6 +446,10 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
/* proxy_util.c */
+PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, const char *balancer_name);
+PROXY_DECLARE(void) proxy_create_comarea(apr_pool_t *pconf);
+PROXY_DECLARE(void) proxy_lookup_storage_provider();
+
PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
PROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
@@ -716,6 +720,7 @@ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
apr_bucket_brigade *brigade);
+
/* Scoreboard */
#if MODULE_MAGIC_NUMBER_MAJOR > 20020903
#define PROXY_HAS_SCOREBOARD 1
diff --git a/modules/proxy/mod_proxy_health_checker.c b/modules/proxy/mod_proxy_health_checker.c
index 56655229ac..010a27dcdd 100644
--- a/modules/proxy/mod_proxy_health_checker.c
+++ b/modules/proxy/mod_proxy_health_checker.c
@@ -18,7 +18,7 @@ static int healthck_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp)
{
slotmem_storage_method *checkstorage;
- health_worker_method *worker_storage = health_checker_get_storage();
+ const health_worker_method *worker_storage = health_checker_get_storage();
ap_slotmem_t *myscore;
checkstorage = ap_lookup_provider(SLOTMEM_STORAGE, "shared", "0");
@@ -51,15 +51,11 @@ static int healthck_post_config(apr_pool_t *pconf, apr_pool_t *plog,
static void ap_healthstore_register_hook(apr_pool_t *p)
{
- static const char * const aszPre[] = { "mod_proxy.c", NULL };
static const char * const aszPos[] = { "mod_sharedmem.c", NULL };
- health_worker_method *worker_storage = health_checker_get_storage();
+ const health_worker_method *worker_storage = health_checker_get_storage();
ap_register_provider(p, PROXY_CKMETHOD, "default", "0", worker_storage);
ap_hook_pre_config(healthck_pre_config, NULL, aszPos, APR_HOOK_MIDDLE);
- /* XXX: Too late....
- ap_hook_post_config(healthck_post_config, aszPre, NULL, APR_HOOK_MIDDLE);
- */
}
module AP_MODULE_DECLARE_DATA proxy_health_checker_module = {
diff --git a/modules/proxy/mod_proxy_health_checker.h b/modules/proxy/mod_proxy_health_checker.h
index a4ec9ba3bf..dcb440c7ec 100644
--- a/modules/proxy/mod_proxy_health_checker.h
+++ b/modules/proxy/mod_proxy_health_checker.h
@@ -29,9 +29,9 @@ typedef struct proxy_worker_conf proxy_worker_conf;
/* allow health check method on workers in a non httpd process */
struct health_worker_method {
/* read the size of the entry: to create the shared area */
- int (* getentrysize)();
+ int (* getentrysize)(void);
/* copy the worker information in the shared area so the health-checker can extract the part it need */
- apr_status_t (*add_entry)(proxy_worker *worker, char *balancer_name, int id);
+ apr_status_t (*add_entry)(proxy_worker *worker, const char *balancer_name, int id);
/* XXX : Remove the entry */
apr_status_t (*del_entry)(int id);
/* read the health of the entry: for httpd */
@@ -39,7 +39,7 @@ struct health_worker_method {
/* set the health of the entry: for the health-checker */
apr_status_t (*set_health)(int id, int value);
/* read the entry stored in the shared area */
- apr_status_t (*get_entry)(proxy_worker **worker, char **balancer_name, apr_pool_t *pool);
+ apr_status_t (*get_entry)(int id, proxy_worker **worker, char **balancer_name, apr_pool_t *pool);
/* read the conf part. */
apr_status_t (*get_entryconf)(int id, proxy_worker_conf **worker, char **balancer_name, apr_pool_t *pool);
/* check the back-end server health */
@@ -96,3 +96,10 @@ struct proxy_worker_conf {
apr_time_t time_checked;
};
+/*
+ * Other routines.
+ */
+const health_worker_method *health_checker_get_storage();
+void health_checker_init_slotmem_storage(const slotmem_storage_method * storage);
+void health_checker_init_slotmem(ap_slotmem_t *score);
+const slotmem_storage_method * health_checker_get_slotmem_storage();
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
index 2fed720313..70a97c7f06 100644
--- a/modules/proxy/proxy_util.c
+++ b/modules/proxy/proxy_util.c
@@ -2251,7 +2251,7 @@ PROXY_DECLARE(void) proxy_lookup_storage_provider()
}
/* Store the worker information in the comarea */
-PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, char *balancer_name)
+PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, const char *balancer_name)
{
if (checkstorage) {
checkstorage->add_entry(worker, balancer_name, worker->id);
diff --git a/support/proxymonitor.c b/support/proxymonitor.c
index 0147b35f33..6619c22f4f 100644
--- a/support/proxymonitor.c
+++ b/support/proxymonitor.c
@@ -36,8 +36,9 @@
#include "mod_proxy.h"
#include "ajp.h"
-#include "mod_proxy_health_checker.h"
#include "slotmem.h"
+#include "sharedmem_util.h"
+#include "mod_proxy_health_checker.h"
#if APR_HAVE_UNISTD_H
#include <unistd.h>
@@ -50,7 +51,7 @@ static int interrupted; /* flag: true if SIGINT or SIGTERM occurred */
static apr_time_t now; /* start time of this processing run */
-extern int AP_DECLARE_DATA ap_default_loglevel = APLOG_ERR;
+extern int AP_DECLARE_DATA ap_default_loglevel;
static apr_file_t *errfile; /* stderr file handle */
static apr_file_t *outfile; /* stdout file handle */
@@ -67,7 +68,7 @@ static apr_status_t init_healthck(apr_pool_t *pool, int *num)
{
apr_size_t size;
apr_status_t rv;
- slotmem_storage_method *checkstorage;
+ const slotmem_storage_method *checkstorage;
ap_slotmem_t *myscore;
sharedmem_initglobalpool(pool);