mod_slotmem_plain.c revision 0a3023a0da3d8aa77cef7805b261ffee8ee01250
/* 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
*
*
* 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 plain memory divided in slot.
* This one uses plain memory.
*/
#include "ap_slotmem.h"
struct ap_slotmem_instance_t {
char *name; /* per segment name */
void *base; /* data set start */
unsigned int num; /* number of mem slots */
char *inuse; /* in-use flag table*/
};
/* global pool and list of slotmem we are handling */
static apr_status_t slotmem_do(ap_slotmem_instance_t *mem, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
{
unsigned int i;
char *ptr;
char *inuse;
if (!mem)
return APR_ENOSHMAVAIL;
if (!AP_SLOTMEM_IS_PREGRAB(mem) ||
if (retval != APR_SUCCESS)
break;
}
}
return retval;
}
static apr_status_t slotmem_create(ap_slotmem_instance_t **new, const char *name, apr_size_t item_size, unsigned int item_num, ap_slotmem_type_t type, apr_pool_t *pool)
{
const char *fname;
if (name) {
if (name[0] == ':')
else
/* first try to attach to existing slotmem */
if (next) {
for (;;) {
/* we already have it */
return APR_SUCCESS;
}
break;
}
}
}
}
else
fname = "anonymous";
/* create the memory using the gpool */
return APR_ENOSHMAVAIL;
/* For the chained slotmem stuff */
if (globallistmem == NULL)
globallistmem = res;
else
return APR_SUCCESS;
}
static apr_status_t slotmem_attach(ap_slotmem_instance_t **new, const char *name, apr_size_t *item_size, unsigned int *item_num, apr_pool_t *pool)
{
const char *fname;
if (name) {
if (name[0] == ':')
else
}
else
return APR_ENOSHMAVAIL;
/* first try to attach to existing slotmem */
while (next) {
/* we already have it */
return APR_SUCCESS;
}
}
return APR_ENOSHMAVAIL;
}
{
char *ptr;
if (!score)
return APR_ENOSHMAVAIL;
return APR_ENOSHMAVAIL;
if (!ptr)
return APR_ENOSHMAVAIL;
return APR_SUCCESS;
}
static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, unsigned char *dest, apr_size_t dest_len)
{
void *ptr;
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_NOTFOUND;
}
if (ret != APR_SUCCESS) {
return ret;
}
*inuse=1;
return APR_SUCCESS;
}
static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, unsigned char *src, apr_size_t src_len)
{
void *ptr;
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_NOTFOUND;
}
if (ret != APR_SUCCESS) {
return ret;
}
*inuse=1;
return APR_SUCCESS;
}
{
}
{
unsigned int i, counter=0;
if (!*inuse)
counter++;
}
return counter;
}
{
}
/*
* XXXX: if !AP_SLOTMEM_IS_PREGRAB, then still worry about
* inuse for grab and return?
*/
{
unsigned int i;
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
if (!*inuse) {
break;
}
}
return APR_ENOSHMAVAIL;
}
*inuse = 1;
*id = i;
return APR_SUCCESS;
}
{
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_NOTFOUND;
}
return APR_SUCCESS;
}
static const ap_slotmem_provider_t storage = {
"plainmem",
};
{
gpool = p;
return OK;
}
static void ap_slotmem_plain_register_hook(apr_pool_t *p)
{
/* XXX: static const char * const prePos[] = { "mod_slotmem.c", NULL }; */
}
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command apr_table_t */
ap_slotmem_plain_register_hook /* register hooks */
};