mod_sharedmem.c revision fcc0e499013bdb7b48eea3aaa1a00d690e318cda
/* 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.
*/
#include "mod_slotmem.h"
/* The description of the slots to reuse the slotmem */
struct sharedslotdesc {
int item_num;
};
/* global pool and list of slotmem we are handling */
static apr_global_mutex_t *smutex;
static const char *mutex_fname;
/*
* Persiste the slotmem in a file
* slotmem name and file name.
* anonymous : $server_root/logs/anonymous.slotmem
* abs_name : $abs_name.slotmem
*
*/
{
const char *storename;
const char *fname;
else if (slotmemname[0] == ':') {
const char *tmpname;
}
else {
fname = slotmemname;
}
return storename;
}
{
apr_file_t *fp;
const char *storename;
rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->gpool);
if (APR_STATUS_IS_EEXIST(rv)) {
rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->gpool);
}
if (rv != APR_SUCCESS) {
return;
}
}
static void restore_slotmem(void *ptr, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
{
const char *storename;
apr_file_t *fp;
if (rv == APR_SUCCESS) {
}
else {
return;
}
}
}
}
{
if (*mem) {
while (next) {
}
}
return APR_SUCCESS;
}
static apr_status_t slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
{
int i;
void *ptr;
if (!mem) {
return APR_ENOSHMAVAIL;
}
}
return APR_SUCCESS;
}
static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
{
/* void *slotmem = NULL; */
void *ptr;
struct sharedslotdesc desc;
const char *fname;
return APR_ENOSHMAVAIL;
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";
}
/* first try to attach to existing shared memory */
}
else {
rv = APR_EINVAL;
}
if (rv == APR_SUCCESS) {
/* check size */
return APR_EINVAL;
}
return APR_EINVAL;
}
}
else {
}
else {
}
if (rv != APR_SUCCESS) {
return rv;
}
}
/* For the chained slotmem stuff */
if (globallistmem == NULL) {
globallistmem = res;
}
else {
}
return APR_SUCCESS;
}
static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool)
{
/* void *slotmem = NULL; */
void *ptr;
struct sharedslotdesc desc;
const char *fname;
return APR_ENOSHMAVAIL;
}
if (name) {
if (name[0] == ':') {
}
else {
}
}
else {
return APR_ENOSHMAVAIL;
}
/* first try to attach to existing slotmem */
if (next) {
for (;;) {
/* we already have it */
return APR_SUCCESS;
}
break;
}
}
/* first try to attach to existing shared memory */
if (rv != APR_SUCCESS) {
return rv;
}
/* Read the description of the slotmem */
/* For the chained slotmem stuff */
if (globallistmem == NULL) {
globallistmem = res;
}
else {
}
return APR_SUCCESS;
}
{
void *ptr;
if (!slot) {
return APR_ENOSHMAVAIL;
}
return APR_ENOSHMAVAIL;
}
if (!ptr) {
return APR_ENOSHMAVAIL;
}
return APR_SUCCESS;
}
{
}
{
}
static const ap_slotmem_storage_method storage = {
};
/* make the storage usuable from outside */
static const ap_slotmem_storage_method *sharedmem_getstorage(void)
{
return (&storage);
}
/* initialise the global pool */
static void sharedmem_initgpool(apr_pool_t *p)
{
gpool = p;
}
/* Add the pool_clean routine */
static void sharedmem_initialize_cleanup(apr_pool_t *p)
{
}
/*
* Create the shared mem mutex and
* make sure the shared memory is cleaned
*/
{
const char *temp_dir;
char *template;
void *data;
const char *userdata_key = "sharedmem_post_config";
if (!data) {
return OK;
}
if (rv != APR_SUCCESS) {
"sharedmem: search for temporary directory failed");
return rv;
}
APR_FILEPATH_NATIVE, p);
if (rv != APR_SUCCESS) {
"sharedmem: creation of mutex file in directory %s failed",
temp_dir);
return rv;
}
if (rv != APR_SUCCESS) {
"sharedmem: unable to get mutex fname");
return rv;
}
mutex_fname, APR_LOCK_DEFAULT, p);
if (rv != APR_SUCCESS) {
"sharedmem: creation of mutex failed");
return rv;
}
#ifdef AP_NEED_SET_MUTEX_PERMS
if (rv != APR_SUCCESS) {
"sharedmem: failed to set mutex permissions");
return rv;
}
#endif
return OK;
}
{
if (rv != APR_SUCCESS) {
"Fatal error: unable to create global pool for shared slotmem");
return rv;
}
return OK;
}
{
mutex_fname, p);
if (rv != APR_SUCCESS) {
"Failed to initialise global mutex %s in child process %"
APR_PID_T_FMT ".",
mutex_fname, getpid());
}
}
static void ap_sharedmem_register_hook(apr_pool_t *p)
{
}
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_sharedmem_register_hook /* register hooks */
};