/* 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 shared memory divided in slot.
* This one uses shared memory.
*
* Shared memory is cleaned-up for each restart, graceful or
* otherwise.
*/
#include "ap_slotmem.h"
#include "httpd.h"
#include "http_main.h"
#ifdef AP_NEED_SET_MUTEX_PERMS
#include "unixd.h"
#endif
#include <unistd.h> /* for getpid() */
#endif
#if HAVE_SYS_SEM_H
#if !defined(SHM_R)
#endif
#if !defined(SHM_W)
#endif
#endif
/* The description of the slots to reuse the slotmem */
typedef struct {
struct ap_slotmem_instance_t {
};
/*
* Memory layout:
* sharedslotdesc_t | num_free | slots | isuse array |
* ^ ^
* | . base
* . persist (also num_free)
*/
/* global pool and list of slotmem we are handling */
/*
* Persist the slotmem in a file
* slotmem name and file name.
* none : no persistent data
* rel_name : $server_root/rel_name
* /abs_name : $abs_name
*
*/
int persist)
{
const char *fname;
return NULL;
}
else if (slotmemname[0] != '/') {
NULL);
}
else {
fname = slotmemname;
}
if (persist) {
NULL);
}
return fname;
}
{
unsigned int i;
char *inuse;
if (!slot) {
return;
}
if (*inuse) {
*inuse = 0;
}
}
}
{
const char *storename;
"storing %s", storename);
if (storename) {
if (APR_STATUS_IS_EEXIST(rv)) {
}
if (rv != APR_SUCCESS) {
return;
}
if (AP_SLOTMEM_IS_CLEARINUSE(slotmem)) {
}
if (rv == APR_SUCCESS) {
}
if (rv != APR_SUCCESS) {
}
}
}
{
const char *storename;
"restoring %s", storename);
if (storename) {
pool);
if (rv == APR_SUCCESS) {
/*
* if at EOF, don't bother checking md5
* - backwards compatibility
* */
ds == APR_MD5_DIGESTSIZE) {
rv = APR_SUCCESS;
rv = APR_EGENERAL;
}
}
}
else {
}
}
rv = APR_EGENERAL;
}
}
}
return rv;
}
{
if (*mem) {
while (next) {
if (AP_SLOTMEM_IS_PERSIST(next)) {
}
const char *name;
if (name) {
}
}
}
}
/* apr_pool_destroy(gpool); */
return APR_SUCCESS;
}
{
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;
}
unsigned int item_num,
{
/* void *slotmem = NULL; */
int restored = 0;
char *ptr;
const char *fname;
return APR_ENOSHMAVAIL;
}
if (fname) {
/* first try to attach to existing slotmem */
if (next) {
for (;;) {
/* we already have it */
"create found %s in global list", fname);
return APR_SUCCESS;
}
break;
}
}
}
"create didn't find %s in global list", fname);
}
else {
fbased = 0;
fname = "none";
}
/* first try to attach to existing shared memory */
item_num);
if (fbased) {
}
else {
rv = APR_EINVAL;
}
if (rv == APR_SUCCESS) {
"apr_shm_attach() succeeded");
/* check size */
"existing shared memory for %s could not be used (failed size check)",
fname);
return APR_EINVAL;
}
"existing shared memory for %s could not be used (failed contents check)",
fname);
return APR_EINVAL;
}
ptr += AP_SLOTMEM_OFFSET;
}
else {
if (fbased) {
}
else {
}
"create: apr_shm_create(%s) %s",
if (rv != APR_SUCCESS) {
return rv;
}
ptr += AP_SLOTMEM_OFFSET;
/*
* TODO: Error check the below... What error makes
* sense if the restore fails? Any?
*/
if (type & AP_SLOTMEM_TYPE_PERSIST) {
if (rv == APR_SUCCESS) {
restored = 1;
}
else {
/* just in case, re-zero */
}
}
}
/* For the chained slotmem stuff */
sizeof(ap_slotmem_instance_t));
if (!restored) {
}
if (globallistmem == NULL) {
globallistmem = res;
}
else {
}
return APR_SUCCESS;
}
{
/* void *slotmem = NULL; */
char *ptr;
const char *fname;
return APR_ENOSHMAVAIL;
}
if (!fname) {
return APR_ENOSHMAVAIL;
}
"attach looking for %s", fname);
/* first try to attach to existing slotmem */
if (next) {
for (;;) {
/* we already have it */
APLOGNO(02302)
return APR_SUCCESS;
}
break;
}
}
}
/* next try to attach to existing shared memory */
if (rv != APR_SUCCESS) {
return rv;
}
/* Read the description of the slotmem */
ptr += AP_SLOTMEM_OFFSET;
/* For the chained slotmem stuff */
sizeof(ap_slotmem_instance_t));
if (globallistmem == NULL) {
globallistmem = res;
}
else {
}
APLOGNO(02303)
return APR_SUCCESS;
}
{
char *ptr;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_EINVAL;
}
if (!ptr) {
return APR_ENOSHMAVAIL;
}
return APR_SUCCESS;
}
{
void *ptr;
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_EINVAL;
}
return APR_NOTFOUND;
}
if (ret != APR_SUCCESS) {
return ret;
}
*inuse = 1;
return APR_SUCCESS;
}
{
void *ptr;
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_EINVAL;
}
return APR_NOTFOUND;
}
if (ret != APR_SUCCESS) {
return ret;
}
*inuse=1;
return APR_SUCCESS;
}
{
}
{
if (AP_SLOTMEM_IS_PREGRAB(slot))
else {
unsigned int i, counter=0;
if (!*inuse)
counter++;
}
return counter;
}
}
{
}
{
unsigned int i;
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
if (!*inuse) {
break;
}
}
return APR_EINVAL;
}
*inuse = 1;
*id = i;
return APR_SUCCESS;
}
{
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_EINVAL;
}
if (!*inuse) {
*inuse = 1;
}
return APR_SUCCESS;
}
unsigned int id)
{
char *inuse;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_EINVAL;
} else {
return APR_NOTFOUND;
}
}
return APR_SUCCESS;
}
"sharedmem",
};
/* make the storage usuable from outside */
{
return (&storage);
}
/* initialise the global pool */
{
gpool = p;
}
/* Add the pool_clean routine */
{
}
/*
* Make sure the shared memory is cleaned
*/
server_rec *s)
{
return OK;
}
{
return OK;
}
{
}
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_shm_register_hook /* register hooks */
};