]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Arrange the warning. Thanks Jim.
authorJean-Frederic Clere <jfclere@apache.org>
Fri, 28 Jul 2006 23:37:15 +0000 (23:37 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Fri, 28 Jul 2006 23:37:15 +0000 (23:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@426708 13f79535-47bb-0310-9956-ffa450edef68

modules/mem/mod_sharedmem.c
modules/mem/sharedmem_util.c
modules/mem/sharedmem_util.h [new file with mode: 0644]
modules/proxy/health_checker_util.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_health_checker.c
modules/proxy/mod_proxy_health_checker.h
modules/proxy/proxy_util.c
support/proxymonitor.c

index 2b55118f02c2e5846509b0728cc5fc850bcd5020..a41d62656d7ebe357769025bfcd44bae6625178d 100644 (file)
@@ -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);
index a330f1425fd65d149d9c541faa69202ee330ced7..2cf12817c8bbbef49a3410f39c729cb129ea67d9 100644 (file)
@@ -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 (file)
index 0000000..978a78f
--- /dev/null
@@ -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();
index b36cf6c471e3bd69ca61deb13bacfaabd19c0582..932fee32804b0d95a5e449506298a434c4ac49bc 100644 (file)
@@ -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);
 }
index 36c9ef846877ab427fc008abdef19243caa057bb..dcbec49ab4825e948b357fe371201b4a1cfabf0d 100644 (file)
@@ -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
index 56655229acc310afd979c98a5ec201b4b6de52a1..010a27dcdd822a223b8d350f324af828014daff6 100644 (file)
@@ -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 = {
index a4ec9ba3bf713bdad9cc88c65c2a2880bfcaca62..dcb440c7ecae13264691870012f0578b3e6a60d0 100644 (file)
@@ -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();
index 2fed7203136796cb22fe06e2b8a36f6e8513cc58..70a97c7f06608b5ed909a65127bfa230d6137cfb 100644 (file)
@@ -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);
index 0147b35f3376078c31d911737051865880fe1883..6619c22f4fe3e948fe8bcf2c67e9b5121c2b6d29 100644 (file)
@@ -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);