Commit ea1bb804 authored by Jean-Frederic Clere's avatar Jean-Frederic Clere
Browse files

Allow anonymous shared memory.

Arrange the mixing of checker size and proper httpd workers status in proxy_util.
Make slotmem.h multi times includable.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@426900 13f79535-47bb-0310-9956-ffa450edef68
parent 647a7f00
Loading
Loading
Loading
Loading
+28 −16
Original line number Diff line number Diff line
@@ -60,9 +60,13 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
    void *slotmem = NULL;
    ap_slotmem_t *res;
    ap_slotmem_t *next = globallistmem;
    char *fname;
    const char *fname;
    apr_status_t rv;

    if (name) {
        if (name[0] == ':')
            fname = name;
        else
            fname = ap_server_root_relative(pool, name);

        /* first try to attach to existing slotmem */
@@ -78,6 +82,8 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
                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 @@ static apr_status_t ap_slotmem_attach(ap_slotmem_t **new, const char *name, apr_
    void *slotmem = NULL;
    ap_slotmem_t *res;
    ap_slotmem_t *next = globallistmem;
    char *fname;
    const char *fname;
    apr_status_t rv;

    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) {
+35 −17
Original line number Diff line number Diff line
@@ -87,9 +87,13 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
    struct sharedslotdesc desc;
    ap_slotmem_t *res;
    ap_slotmem_t *next = globallistmem;
    char *fname;
    const char *fname;
    apr_status_t rv;

    if (name) {
        if (name[0] == ':')
            fname = name;
        else
            fname = ap_server_root_relative(pool, name);

        /* first try to attach to existing slotmem */
@@ -105,10 +109,15 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
                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));
    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 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
        }
        ptr = ptr +  sizeof(desc);
    } else  {
        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 @@ static apr_status_t ap_slotmem_attach(ap_slotmem_t **new, const char *name, apr_
    ap_slotmem_t *res;
    ap_slotmem_t *next = globallistmem;
    struct sharedslotdesc desc;
    char *fname;
    const char *fname;
    apr_status_t rv;

    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) {
+11 −0
Original line number Diff line number Diff line
@@ -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 @@ AP_DECLARE(apr_status_t) (* ap_slotmem_mem)(ap_slotmem_t *s, int item_id, void**
};

typedef struct slotmem_storage_method slotmem_storage_method;

#endif /*SLOTMEM_H*/
+1 −4
Original line number Diff line number Diff line
@@ -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 @@ PROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s,
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 @@ static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog,
    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);
+2 −1
Original line number Diff line number Diff line
@@ -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 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,

/* 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();

Loading