You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jf...@apache.org on 2006/07/30 19:15:35 UTC
svn commit: r426900 - in
/httpd/httpd/branches/httpd-proxy-scoreboard/modules: mem/mod_plainmem.c
mem/sharedmem_util.c mem/slotmem.h proxy/mod_proxy.c proxy/mod_proxy.h
proxy/proxy_util.c
Author: jfclere
Date: Sun Jul 30 10:15:34 2006
New Revision: 426900
URL: http://svn.apache.org/viewvc?rev=426900&view=rev
Log:
Allow anonymous shared memory.
Arrange the mixing of checker size and proper httpd workers status in proxy_util.
Make slotmem.h multi times includable.
Modified:
httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/mod_plainmem.c
httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/sharedmem_util.c
httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/slotmem.h
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.c
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.h
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/mod_plainmem.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/mod_plainmem.c?rev=426900&r1=426899&r2=426900&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/mod_plainmem.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/mod_plainmem.c Sun Jul 30 10:15:34 2006
@@ -60,24 +60,30 @@
void *slotmem = NULL;
ap_slotmem_t *res;
ap_slotmem_t *next = globallistmem;
- char *fname;
+ const char *fname;
apr_status_t rv;
- fname = ap_server_root_relative(pool, name);
-
- /* first try to attach to existing slotmem */
- if (next) {
- for (;;) {
- if (strcmp(next->name, fname) == 0) {
- /* we already have it */
- *new = next;
- return APR_SUCCESS;
+ if (name) {
+ if (name[0] == ':')
+ fname = name;
+ else
+ fname = ap_server_root_relative(pool, name);
+
+ /* first try to attach to existing slotmem */
+ if (next) {
+ for (;;) {
+ if (strcmp(next->name, fname) == 0) {
+ /* we already have it */
+ *new = next;
+ return APR_SUCCESS;
+ }
+ if (!next->next)
+ break;
+ next = next->next;
}
- if (!next->next)
- break;
- next = next->next;
}
- }
+ } else
+ fname = "anonymous";
/* create the memory using the globalpool */
res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
@@ -104,10 +110,16 @@
void *slotmem = NULL;
ap_slotmem_t *res;
ap_slotmem_t *next = globallistmem;
- char *fname;
+ const char *fname;
apr_status_t rv;
- fname = ap_server_root_relative(pool, name);
+ if (name) {
+ if (name[0] == ':')
+ fname = name;
+ else
+ fname = ap_server_root_relative(pool, name);
+ } else
+ return APR_ENOSHMAVAIL;
/* first try to attach to existing slotmem */
if (next) {
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/sharedmem_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/sharedmem_util.c?rev=426900&r1=426899&r2=426900&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/sharedmem_util.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/sharedmem_util.c Sun Jul 30 10:15:34 2006
@@ -87,28 +87,37 @@
struct sharedslotdesc desc;
ap_slotmem_t *res;
ap_slotmem_t *next = globallistmem;
- char *fname;
+ const char *fname;
apr_status_t rv;
- fname = ap_server_root_relative(pool, name);
-
- /* first try to attach to existing slotmem */
- if (next) {
- for (;;) {
- if (strcmp(next->name, fname) == 0) {
- /* we already have it */
- *new = next;
- return APR_SUCCESS;
+ if (name) {
+ if (name[0] == ':')
+ fname = name;
+ else
+ fname = ap_server_root_relative(pool, name);
+
+ /* first try to attach to existing slotmem */
+ if (next) {
+ for (;;) {
+ if (strcmp(next->name, fname) == 0) {
+ /* we already have it */
+ *new = next;
+ return APR_SUCCESS;
+ }
+ if (!next->next)
+ break;
+ next = next->next;
}
- if (!next->next)
- break;
- next = next->next;
}
- }
+ } else
+ fname = "anonymous";
/* first try to attach to existing shared memory */
res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
- rv = apr_shm_attach(&res->shm, fname, globalpool);
+ if (name && name[0] != ':')
+ rv = apr_shm_attach(&res->shm, fname, globalpool);
+ else
+ rv = APR_EINVAL;
if (rv == APR_SUCCESS) {
/* check size */
if (apr_shm_size_get(res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
@@ -125,7 +134,10 @@
}
ptr = ptr + sizeof(desc);
} else {
- rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, globalpool);
+ if (name && name[0] != ':')
+ rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, globalpool);
+ else
+ rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, globalpool);
if (rv != APR_SUCCESS)
return rv;
ptr = apr_shm_baseaddr_get(res->shm);
@@ -158,10 +170,16 @@
ap_slotmem_t *res;
ap_slotmem_t *next = globallistmem;
struct sharedslotdesc desc;
- char *fname;
+ const char *fname;
apr_status_t rv;
- fname = ap_server_root_relative(pool, name);
+ if (name) {
+ if (name[0] == ':')
+ fname = name;
+ else
+ fname = ap_server_root_relative(pool, name);
+ } else
+ return APR_ENOSHMAVAIL;
/* first try to attach to existing slotmem */
if (next) {
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/slotmem.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/slotmem.h?rev=426900&r1=426899&r2=426900&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/slotmem.h (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/mem/slotmem.h Sun Jul 30 10:15:34 2006
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#ifndef SLOTMEM_H
#define SLOTMEM_H
/* Memory handler for a shared memory divided in slot.
@@ -27,6 +28,14 @@
* @{
*/
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_shm.h"
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_log.h"
#define SLOTMEM_STORAGE "slotmem"
@@ -86,3 +95,5 @@
};
typedef struct slotmem_storage_method slotmem_storage_method;
+
+#endif /*SLOTMEM_H*/
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.c?rev=426900&r1=426899&r2=426900&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.c Sun Jul 30 10:15:34 2006
@@ -17,7 +17,6 @@
#define CORE_PRIVATE
#include "mod_proxy.h"
-#include "slotmem.h"
#include "mod_core.h"
#include "apr_optional.h"
#include "scoreboard.h"
@@ -1863,8 +1862,6 @@
static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- proxy_server_conf *sconf = ap_get_module_config(s->module_config,
- &proxy_module);
proxy_ssl_enable = APR_RETRIEVE_OPTIONAL_FN(ssl_proxy_enable);
proxy_ssl_disable = APR_RETRIEVE_OPTIONAL_FN(ssl_engine_disable);
@@ -1872,7 +1869,7 @@
proxy_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
/* if we have a memory provider create the comarea here */
- proxy_create_comarea(pconf, sconf->slotmem_loc);
+ proxy_create_comarea(pconf, s);
/* Also fill the comarea of the health-checker */
proxy_checkstorage_add_workers(pconf, s);
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.h?rev=426900&r1=426899&r2=426900&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy.h Sun Jul 30 10:15:34 2006
@@ -74,6 +74,7 @@
#include "util_filter.h"
#include "util_ebcdic.h"
#include "ap_provider.h"
+#include "slotmem.h"
#if APR_HAVE_NETINET_IN_H
#include <netinet/in.h>
@@ -447,7 +448,7 @@
/* proxy_util.c */
-PROXY_DECLARE(void) proxy_create_comarea(apr_pool_t *pconf, char *name);
+PROXY_DECLARE(ap_slotmem_t *) proxy_create_comarea(apr_pool_t *pconf, server_rec *s);
PROXY_DECLARE(void) proxy_checkstorage_add_workers(apr_pool_t *pconf, server_rec *s);
PROXY_DECLARE(void) proxy_lookup_storage_provider();
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c?rev=426900&r1=426899&r2=426900&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c Sun Jul 30 10:15:34 2006
@@ -16,7 +16,6 @@
/* Utility routines for Apache proxy */
#include "mod_proxy.h"
-#include "slotmem.h"
#include "mod_proxy_health_checker.h"
#include "ap_mpm.h"
#include "apr_version.h"
@@ -1633,7 +1632,6 @@
void *score = NULL;
ap_slotmem_t *myscore;
apr_status_t rv;
- apr_size_t item_size = sizeof(proxy_worker_stat);
proxy_server_conf *sconf = ap_get_module_config(s->module_config,
&proxy_module);
@@ -1645,16 +1643,11 @@
return;
}
- /* Health checker handler: to create the correct size. */
- if (checkstorage) {
- item_size = checkstorage->getentrysize();
- }
-
/* Use storage provider when a storage is existing */
if (storage) {
+ myscore = proxy_create_comarea(conf->pool, s);
- rv = storage->ap_slotmem_create(&myscore, sconf->slotmem_loc, item_size, ap_proxy_lb_workers(), conf->pool);
- if (rv == APR_SUCCESS)
+ if (myscore)
rv = storage->ap_slotmem_mem(myscore, worker->id, &score);
if (rv != APR_SUCCESS)
score = NULL;
@@ -2232,14 +2225,19 @@
}
/* Create shared area (comarea) called from mod_proxy post_config */
-PROXY_DECLARE(void) proxy_create_comarea(apr_pool_t *pconf, char *name)
+PROXY_DECLARE(ap_slotmem_t *) proxy_create_comarea(apr_pool_t *pconf, server_rec *s)
{
- ap_slotmem_t *myscore;
- apr_size_t item_size = sizeof(proxy_worker_stat);
- if (checkstorage)
- item_size = checkstorage->getentrysize();
- if (storage)
- storage->ap_slotmem_create(&myscore, name, item_size, ap_proxy_lb_workers(), pconf);
+ ap_slotmem_t *myscore = NULL;
+ proxy_server_conf *sconf = ap_get_module_config(s->module_config,
+ &proxy_module);
+ char *slotmem_loc = sconf->slotmem_loc;
+
+ if (storage) {
+ if (!slotmem_loc)
+ slotmem_loc = apr_pstrcat(pconf, ":", proxy_module.name, NULL);
+ storage->ap_slotmem_create(&myscore, slotmem_loc, sizeof(proxy_worker_stat), ap_proxy_lb_workers(), pconf);
+ }
+ return(myscore);
}
/* get the storage provider for the shared area called from mod_proxy pre_config */
PROXY_DECLARE(void) proxy_lookup_storage_provider()