diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:33:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:33:50 +0000 |
commit | fe39ffb8b90ae4e002ed73fe98617cd590abb467 (patch) | |
tree | b80e5956907d8aeaaffe4e4f0c068c0e6157ce8b /modules/slotmem | |
parent | Initial commit. (diff) | |
download | apache2-fe39ffb8b90ae4e002ed73fe98617cd590abb467.tar.xz apache2-fe39ffb8b90ae4e002ed73fe98617cd590abb467.zip |
Adding upstream version 2.4.56.upstream/2.4.56
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/slotmem')
-rw-r--r-- | modules/slotmem/Makefile.in | 3 | ||||
-rw-r--r-- | modules/slotmem/NWGNUmakefile | 246 | ||||
-rw-r--r-- | modules/slotmem/NWGNUslotmem_plain | 250 | ||||
-rw-r--r-- | modules/slotmem/NWGNUslotmem_shm | 250 | ||||
-rw-r--r-- | modules/slotmem/config.m4 | 10 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_plain.c | 343 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_plain.dep | 51 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_plain.dsp | 111 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_plain.mak | 353 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_shm.c | 788 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_shm.dep | 57 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_shm.dsp | 111 | ||||
-rw-r--r-- | modules/slotmem/mod_slotmem_shm.mak | 353 |
13 files changed, 2926 insertions, 0 deletions
diff --git a/modules/slotmem/Makefile.in b/modules/slotmem/Makefile.in new file mode 100644 index 0000000..7c5c149 --- /dev/null +++ b/modules/slotmem/Makefile.in @@ -0,0 +1,3 @@ +# a modules Makefile has no explicit targets -- they will be defined by +# whatever modules are enabled. just grab special.mk to deal with this. +include $(top_srcdir)/build/special.mk diff --git a/modules/slotmem/NWGNUmakefile b/modules/slotmem/NWGNUmakefile new file mode 100644 index 0000000..bdde37d --- /dev/null +++ b/modules/slotmem/NWGNUmakefile @@ -0,0 +1,246 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)/build/NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/slotmem_plain.nlm \ + $(OBJDIR)/slotmem_shm.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + $(call COPY,$(OBJDIR)/*.nlm, $(INSTALLBASE)/modules/) + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/slotmem/NWGNUslotmem_plain b/modules/slotmem/NWGNUslotmem_plain new file mode 100644 index 0000000..a66504a --- /dev/null +++ b/modules/slotmem/NWGNUslotmem_plain @@ -0,0 +1,250 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)/build/NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(AP_WORK)/include \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = slotmem_plain + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Slotmem Plain Module + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = Slotmem Plain Module + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/$(NLM_NAME).nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/mod_slotmem_plain.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(PRELUDE) \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @aprlib.imp \ + @httpd.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + slotmem_plain_module \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +vpath %.c ../arch/netware + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/slotmem/NWGNUslotmem_shm b/modules/slotmem/NWGNUslotmem_shm new file mode 100644 index 0000000..5155693 --- /dev/null +++ b/modules/slotmem/NWGNUslotmem_shm @@ -0,0 +1,250 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)/build/NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(AP_WORK)/include \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = slotmem_shm + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Slotmem SHM Module + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = Slotmem SHM Module + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/$(NLM_NAME).nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/mod_slotmem_shm.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(PRELUDE) \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @aprlib.imp \ + @httpd.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + slotmem_shm_module \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +vpath %.c ../arch/netware + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/slotmem/config.m4 b/modules/slotmem/config.m4 new file mode 100644 index 0000000..82d13bb --- /dev/null +++ b/modules/slotmem/config.m4 @@ -0,0 +1,10 @@ +dnl modules enabled in this directory by default + +dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]]) + +APACHE_MODPATH_INIT(slotmem) + +APACHE_MODULE(slotmem_shm, slotmem provider that uses shared memory, , , most) +APACHE_MODULE(slotmem_plain, slotmem provider that uses plain memory, , , ) + +APACHE_MODPATH_FINISH diff --git a/modules/slotmem/mod_slotmem_plain.c b/modules/slotmem/mod_slotmem_plain.c new file mode 100644 index 0000000..4c2b19b --- /dev/null +++ b/modules/slotmem/mod_slotmem_plain.c @@ -0,0 +1,343 @@ +/* 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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" + +#define AP_SLOTMEM_IS_PREGRAB(t) (t->type & AP_SLOTMEM_TYPE_PREGRAB) + +struct ap_slotmem_instance_t { + char *name; /* per segment name */ + void *base; /* data set start */ + apr_size_t size; /* size of each memory slot */ + unsigned int num; /* number of mem slots */ + apr_pool_t *gpool; /* per segment global pool */ + char *inuse; /* in-use flag table*/ + ap_slotmem_type_t type; /* type-specific flags */ + struct ap_slotmem_instance_t *next; /* location of next allocated segment */ +}; + + +/* global pool and list of slotmem we are handling */ +static struct ap_slotmem_instance_t *globallistmem = NULL; +static apr_pool_t *gpool = NULL; + +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; + apr_status_t retval = APR_SUCCESS; + + + if (!mem) + return APR_ENOSHMAVAIL; + + ptr = (char *)mem->base; + inuse = mem->inuse; + for (i = 0; i < mem->num; i++, inuse++) { + if (!AP_SLOTMEM_IS_PREGRAB(mem) || + (AP_SLOTMEM_IS_PREGRAB(mem) && *inuse)) { + retval = func((void *) ptr, data, pool); + if (retval != APR_SUCCESS) + break; + } + ptr += mem->size; + } + 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) +{ + ap_slotmem_instance_t *res; + ap_slotmem_instance_t *next = globallistmem; + apr_size_t basesize = (item_size * item_num); + + const char *fname; + + if (name) { + if (name[0] == ':') + fname = name; + else + fname = ap_runtime_dir_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; + } + } + } + else + fname = "anonymous"; + + /* create the memory using the gpool */ + res = (ap_slotmem_instance_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_instance_t)); + res->base = apr_pcalloc(gpool, basesize + (item_num * sizeof(char))); + if (!res->base) + return APR_ENOSHMAVAIL; + + /* For the chained slotmem stuff */ + res->name = apr_pstrdup(gpool, fname); + res->size = item_size; + res->num = item_num; + res->next = NULL; + res->type = type; + res->inuse = (char *)res->base + basesize; + if (globallistmem == NULL) + globallistmem = res; + else + next->next = res; + + *new = res; + 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) +{ + ap_slotmem_instance_t *next = globallistmem; + const char *fname; + + if (name) { + if (name[0] == ':') + fname = name; + else + fname = ap_runtime_dir_relative(pool, name); + } + else + return APR_ENOSHMAVAIL; + + /* first try to attach to existing slotmem */ + while (next) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + *item_size = next->size; + *item_num = next->num; + return APR_SUCCESS; + } + next = next->next; + } + + return APR_ENOSHMAVAIL; +} + +static apr_status_t slotmem_dptr(ap_slotmem_instance_t *score, unsigned int id, void **mem) +{ + + char *ptr; + + if (!score) + return APR_ENOSHMAVAIL; + if (id >= score->num) + return APR_EINVAL; + + ptr = (char *)score->base + score->size * id; + if (!ptr) + return APR_ENOSHMAVAIL; + *mem = ptr; + 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; + apr_status_t ret; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse + id; + if (id >= slot->num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { + return APR_NOTFOUND; + } + ret = slotmem_dptr(slot, id, &ptr); + if (ret != APR_SUCCESS) { + return ret; + } + *inuse=1; + memcpy(dest, ptr, dest_len); /* bounds check? */ + 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; + apr_status_t ret; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse + id; + if (id >= slot->num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { + return APR_NOTFOUND; + } + ret = slotmem_dptr(slot, id, &ptr); + if (ret != APR_SUCCESS) { + return ret; + } + *inuse=1; + memcpy(ptr, src, src_len); /* bounds check? */ + return APR_SUCCESS; +} + +static unsigned int slotmem_num_slots(ap_slotmem_instance_t *slot) +{ + return slot->num; +} + +static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) +{ + unsigned int i, counter=0; + char *inuse = slot->inuse; + for (i = 0; i < slot->num; i++, inuse++) { + if (!*inuse) + counter++; + } + return counter; +} + +static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) +{ + return slot->size; +} + +/* + * XXXX: if !AP_SLOTMEM_IS_PREGRAB, then still worry about + * inuse for grab and return? + */ +static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id) +{ + unsigned int i; + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse; + + for (i = 0; i < slot->num; i++, inuse++) { + if (!*inuse) { + break; + } + } + if (i >= slot->num) { + return APR_EINVAL; + } + *inuse = 1; + *id = i; + return APR_SUCCESS; +} + +static apr_status_t slotmem_fgrab(ap_slotmem_instance_t *slot, unsigned int id) +{ + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + if (id >= slot->num) { + return APR_EINVAL; + } + inuse = slot->inuse + id; + *inuse = 1; + return APR_SUCCESS; +} + +static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, unsigned int id) +{ + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse; + + if (id >= slot->num) { + return APR_EINVAL; + } + if (!inuse[id] ) { + return APR_NOTFOUND; + } + inuse[id] = 0; + return APR_SUCCESS; +} + +static const ap_slotmem_provider_t storage = { + "plainmem", + &slotmem_do, + &slotmem_create, + &slotmem_attach, + &slotmem_dptr, + &slotmem_get, + &slotmem_put, + &slotmem_num_slots, + &slotmem_num_free_slots, + &slotmem_slot_size, + &slotmem_grab, + &slotmem_release, + &slotmem_fgrab +}; + +static int pre_config(apr_pool_t *p, apr_pool_t *plog, + apr_pool_t *ptemp) +{ + 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 }; */ + ap_register_provider(p, AP_SLOTMEM_PROVIDER_GROUP, "plain", + AP_SLOTMEM_PROVIDER_VERSION, &storage); + ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE); +} + +AP_DECLARE_MODULE(slotmem_plain) = { + STANDARD20_MODULE_STUFF, + 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 */ +}; + diff --git a/modules/slotmem/mod_slotmem_plain.dep b/modules/slotmem/mod_slotmem_plain.dep new file mode 100644 index 0000000..274535e --- /dev/null +++ b/modules/slotmem/mod_slotmem_plain.dep @@ -0,0 +1,51 @@ +# Microsoft Developer Studio Generated Dependency File, included by mod_slotmem_plain.mak + +..\..\build\win32\httpd.rc : \ + "..\..\include\ap_release.h"\ + + +.\mod_slotmem_plain.c : \ + "..\..\include\ap_config.h"\ + "..\..\include\ap_config_layout.h"\ + "..\..\include\ap_hooks.h"\ + "..\..\include\ap_mmn.h"\ + "..\..\include\ap_provider.h"\ + "..\..\include\ap_regex.h"\ + "..\..\include\ap_release.h"\ + "..\..\include\ap_slotmem.h"\ + "..\..\include\apache_noprobes.h"\ + "..\..\include\http_config.h"\ + "..\..\include\http_log.h"\ + "..\..\include\httpd.h"\ + "..\..\include\os.h"\ + "..\..\include\util_cfgtree.h"\ + "..\..\srclib\apr-util\include\apr_buckets.h"\ + "..\..\srclib\apr-util\include\apr_hooks.h"\ + "..\..\srclib\apr-util\include\apr_md5.h"\ + "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ + "..\..\srclib\apr-util\include\apr_uri.h"\ + "..\..\srclib\apr-util\include\apr_xlate.h"\ + "..\..\srclib\apr-util\include\apu.h"\ + "..\..\srclib\apr\include\apr.h"\ + "..\..\srclib\apr\include\apr_allocator.h"\ + "..\..\srclib\apr\include\apr_errno.h"\ + "..\..\srclib\apr\include\apr_file_info.h"\ + "..\..\srclib\apr\include\apr_file_io.h"\ + "..\..\srclib\apr\include\apr_general.h"\ + "..\..\srclib\apr\include\apr_global_mutex.h"\ + "..\..\srclib\apr\include\apr_inherit.h"\ + "..\..\srclib\apr\include\apr_mmap.h"\ + "..\..\srclib\apr\include\apr_network_io.h"\ + "..\..\srclib\apr\include\apr_poll.h"\ + "..\..\srclib\apr\include\apr_pools.h"\ + "..\..\srclib\apr\include\apr_proc_mutex.h"\ + "..\..\srclib\apr\include\apr_ring.h"\ + "..\..\srclib\apr\include\apr_shm.h"\ + "..\..\srclib\apr\include\apr_strings.h"\ + "..\..\srclib\apr\include\apr_tables.h"\ + "..\..\srclib\apr\include\apr_thread_mutex.h"\ + "..\..\srclib\apr\include\apr_thread_proc.h"\ + "..\..\srclib\apr\include\apr_time.h"\ + "..\..\srclib\apr\include\apr_user.h"\ + "..\..\srclib\apr\include\apr_want.h"\ + diff --git a/modules/slotmem/mod_slotmem_plain.dsp b/modules/slotmem/mod_slotmem_plain.dsp new file mode 100644 index 0000000..023e31c --- /dev/null +++ b/modules/slotmem/mod_slotmem_plain.dsp @@ -0,0 +1,111 @@ +# Microsoft Developer Studio Project File - Name="mod_slotmem_plain" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=mod_slotmem_plain - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "mod_slotmem_plain.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mod_slotmem_plain.mak" CFG="mod_slotmem_plain - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_slotmem_plain - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_slotmem_plain - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_slotmem_plain_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /fo"Release/mod_slotmem_plain.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_slotmem_plain.so" /d LONG_NAME="slotmem_plain_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_slotmem_plain.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_plain.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_slotmem_plain.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_plain.so /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\mod_slotmem_plain.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_slotmem_plain_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /fo"Debug/mod_slotmem_plain.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_slotmem_plain.so" /d LONG_NAME="slotmem_plain_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_slotmem_plain.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_plain.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_slotmem_plain.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_plain.so +# Begin Special Build Tool +TargetPath=.\Debug\mod_slotmem_plain.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "mod_slotmem_plain - Win32 Release" +# Name "mod_slotmem_plain - Win32 Debug" +# Begin Source File + +SOURCE=.\mod_slotmem_plain.c +# End Source File +# Begin Source File + +SOURCE=..\..\build\win32\httpd.rc +# End Source File +# End Target +# End Project diff --git a/modules/slotmem/mod_slotmem_plain.mak b/modules/slotmem/mod_slotmem_plain.mak new file mode 100644 index 0000000..4e7891a --- /dev/null +++ b/modules/slotmem/mod_slotmem_plain.mak @@ -0,0 +1,353 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on mod_slotmem_plain.dsp +!IF "$(CFG)" == "" +CFG=mod_slotmem_plain - Win32 Release +!MESSAGE No configuration specified. Defaulting to mod_slotmem_plain - Win32 Release. +!ENDIF + +!IF "$(CFG)" != "mod_slotmem_plain - Win32 Release" && "$(CFG)" != "mod_slotmem_plain - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mod_slotmem_plain.mak" CFG="mod_slotmem_plain - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_slotmem_plain - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_slotmem_plain - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_slotmem_plain.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_slotmem_plain.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_slotmem_plain.obj" + -@erase "$(INTDIR)\mod_slotmem_plain.res" + -@erase "$(INTDIR)\mod_slotmem_plain_src.idb" + -@erase "$(INTDIR)\mod_slotmem_plain_src.pdb" + -@erase "$(OUTDIR)\mod_slotmem_plain.exp" + -@erase "$(OUTDIR)\mod_slotmem_plain.lib" + -@erase "$(OUTDIR)\mod_slotmem_plain.pdb" + -@erase "$(OUTDIR)\mod_slotmem_plain.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_slotmem_plain_src" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_slotmem_plain.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_slotmem_plain.so" /d LONG_NAME="slotmem_plain_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_slotmem_plain.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_slotmem_plain.pdb" /debug /out:"$(OUTDIR)\mod_slotmem_plain.so" /implib:"$(OUTDIR)\mod_slotmem_plain.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_plain.so /opt:ref +LINK32_OBJS= \ + "$(INTDIR)\mod_slotmem_plain.obj" \ + "$(INTDIR)\mod_slotmem_plain.res" \ + "..\..\srclib\apr\Release\libapr-1.lib" \ + "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ + "..\..\Release\libhttpd.lib" + +"$(OUTDIR)\mod_slotmem_plain.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Release\mod_slotmem_plain.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_slotmem_plain.so" + if exist .\Release\mod_slotmem_plain.so.manifest mt.exe -manifest .\Release\mod_slotmem_plain.so.manifest -outputresource:.\Release\mod_slotmem_plain.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ELSEIF "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_slotmem_plain.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_slotmem_plain.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_slotmem_plain.obj" + -@erase "$(INTDIR)\mod_slotmem_plain.res" + -@erase "$(INTDIR)\mod_slotmem_plain_src.idb" + -@erase "$(INTDIR)\mod_slotmem_plain_src.pdb" + -@erase "$(OUTDIR)\mod_slotmem_plain.exp" + -@erase "$(OUTDIR)\mod_slotmem_plain.lib" + -@erase "$(OUTDIR)\mod_slotmem_plain.pdb" + -@erase "$(OUTDIR)\mod_slotmem_plain.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_slotmem_plain_src" /FD /EHsc /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_slotmem_plain.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_slotmem_plain.so" /d LONG_NAME="slotmem_plain_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_slotmem_plain.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_slotmem_plain.pdb" /debug /out:"$(OUTDIR)\mod_slotmem_plain.so" /implib:"$(OUTDIR)\mod_slotmem_plain.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_plain.so +LINK32_OBJS= \ + "$(INTDIR)\mod_slotmem_plain.obj" \ + "$(INTDIR)\mod_slotmem_plain.res" \ + "..\..\srclib\apr\Debug\libapr-1.lib" \ + "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ + "..\..\Debug\libhttpd.lib" + +"$(OUTDIR)\mod_slotmem_plain.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Debug\mod_slotmem_plain.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_slotmem_plain.so" + if exist .\Debug\mod_slotmem_plain.so.manifest mt.exe -manifest .\Debug\mod_slotmem_plain.so.manifest -outputresource:.\Debug\mod_slotmem_plain.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("mod_slotmem_plain.dep") +!INCLUDE "mod_slotmem_plain.dep" +!ELSE +!MESSAGE Warning: cannot find "mod_slotmem_plain.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" || "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" + +"libapr - Win32 Release" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" + cd "..\..\modules\slotmem" + +"libapr - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ELSEIF "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + +"libapr - Win32 Debug" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" + cd "..\..\modules\slotmem" + +"libapr - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ENDIF + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" + +"libaprutil - Win32 Release" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" + cd "..\..\modules\slotmem" + +"libaprutil - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ELSEIF "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + +"libaprutil - Win32 Debug" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" + cd "..\..\modules\slotmem" + +"libaprutil - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ENDIF + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" + +"libhttpd - Win32 Release" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" + cd ".\modules\slotmem" + +"libhttpd - Win32 ReleaseCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN + cd ".\modules\slotmem" + +!ELSEIF "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + +"libhttpd - Win32 Debug" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" + cd ".\modules\slotmem" + +"libhttpd - Win32 DebugCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN + cd ".\modules\slotmem" + +!ENDIF + +SOURCE=..\..\build\win32\httpd.rc + +!IF "$(CFG)" == "mod_slotmem_plain - Win32 Release" + + +"$(INTDIR)\mod_slotmem_plain.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_slotmem_plain.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "NDEBUG" /d BIN_NAME="mod_slotmem_plain.so" /d LONG_NAME="slotmem_plain_module for Apache" $(SOURCE) + + +!ELSEIF "$(CFG)" == "mod_slotmem_plain - Win32 Debug" + + +"$(INTDIR)\mod_slotmem_plain.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_slotmem_plain.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "_DEBUG" /d BIN_NAME="mod_slotmem_plain.so" /d LONG_NAME="slotmem_plain_module for Apache" $(SOURCE) + + +!ENDIF + +SOURCE=.\mod_slotmem_plain.c + +"$(INTDIR)\mod_slotmem_plain.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/modules/slotmem/mod_slotmem_shm.c b/modules/slotmem/mod_slotmem_shm.c new file mode 100644 index 0000000..f4eaa84 --- /dev/null +++ b/modules/slotmem/mod_slotmem_shm.c @@ -0,0 +1,788 @@ +/* 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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" +#include "ap_mpm.h" /* for ap_mpm_query() */ + +#define AP_SLOTMEM_IS_PREGRAB(t) (t->desc->type & AP_SLOTMEM_TYPE_PREGRAB) +#define AP_SLOTMEM_IS_PERSIST(t) (t->desc->type & AP_SLOTMEM_TYPE_PERSIST) +#define AP_SLOTMEM_IS_CLEARINUSE(t) (t->desc->type & AP_SLOTMEM_TYPE_CLEARINUSE) + +/* The description of the slots to reuse the slotmem */ +typedef struct { + apr_size_t size; /* size of each memory slot */ + unsigned int num; /* number of mem slots */ + ap_slotmem_type_t type; /* type-specific flags */ +} sharedslotdesc_t; + +#define AP_SLOTMEM_OFFSET (APR_ALIGN_DEFAULT(sizeof(sharedslotdesc_t))) +#define AP_UNSIGNEDINT_OFFSET (APR_ALIGN_DEFAULT(sizeof(unsigned int))) + +struct ap_slotmem_instance_t { + char *name; /* file based SHM path/name */ + char *pname; /* persisted file path/name */ + int fbased; /* filebased? */ + void *shm; /* ptr to memory segment (apr_shm_t *) */ + void *base; /* data set start */ + apr_pool_t *gpool; /* per segment pool (generation cleared) */ + char *inuse; /* in-use flag table*/ + unsigned int *num_free; /* slot free count for this instance */ + void *persist; /* persist dataset start */ + const sharedslotdesc_t *desc; /* per slot desc */ + struct ap_slotmem_instance_t *next; /* location of next allocated segment */ +}; + +/* + * Layout for SHM and persisted file : + * + * +-------------------------------------------------------------+~> + * | desc | num_free | base (slots) | inuse (array) | md5 | desc | compat.. + * +------+-----------------------------------------+------------+~> + * ^ ^ ^ \ / ^ : + * |______|_____________ SHM (mem->@) ______________| | _____|__/ + * | |/ | + * | ^ v | + * |_____________________ File (mem->persist + [meta]) __| + */ + +/* global pool and list of slotmem we are handling */ +static struct ap_slotmem_instance_t *globallistmem = NULL; +static apr_pool_t *gpool = NULL; + +#define DEFAULT_SLOTMEM_PREFIX "slotmem-shm-" +#define DEFAULT_SLOTMEM_SUFFIX ".shm" +#define DEFAULT_SLOTMEM_PERSIST_SUFFIX ".persist" + +/* + * 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 + * + */ +static int slotmem_filenames(apr_pool_t *pool, + const char *slotname, + const char **filename, + const char **persistname) +{ + const char *fname = NULL, *pname = NULL; + + if (slotname && *slotname && strcasecmp(slotname, "none") != 0) { + if (slotname[0] != '/') { + /* Each generation needs its own file name. */ + int generation = 0; + ap_mpm_query(AP_MPMQ_GENERATION, &generation); + fname = apr_psprintf(pool, "%s%s_%x%s", DEFAULT_SLOTMEM_PREFIX, + slotname, generation, DEFAULT_SLOTMEM_SUFFIX); + fname = ap_runtime_dir_relative(pool, fname); + } + else { + /* Don't mangle the file name if given an absolute path, it's + * up to the caller to provide a unique name when necessary. + */ + fname = slotname; + } + + if (persistname) { + /* Persisted file names are immutable... */ + if (slotname[0] != '/') { + pname = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX, + slotname, DEFAULT_SLOTMEM_SUFFIX, + DEFAULT_SLOTMEM_PERSIST_SUFFIX, + NULL); + pname = ap_runtime_dir_relative(pool, pname); + } + else { + pname = apr_pstrcat(pool, slotname, + DEFAULT_SLOTMEM_PERSIST_SUFFIX, + NULL); + } + } + } + + *filename = fname; + if (persistname) { + *persistname = pname; + } + return (fname != NULL); +} + +static void slotmem_clearinuse(ap_slotmem_instance_t *slot) +{ + unsigned int i; + char *inuse; + + if (!slot) { + return; + } + + inuse = slot->inuse; + + for (i = 0; i < slot->desc->num; i++, inuse++) { + if (*inuse) { + *inuse = 0; + (*slot->num_free)++; + } + } +} + +static void store_slotmem(ap_slotmem_instance_t *slotmem) +{ + apr_file_t *fp; + apr_status_t rv; + apr_size_t nbytes; + unsigned char digest[APR_MD5_DIGESTSIZE]; + const char *storename = slotmem->pname; + + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02334) + "storing %s", storename); + + if (storename) { + rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, + APR_OS_DEFAULT, slotmem->gpool); + if (APR_STATUS_IS_EEXIST(rv)) { + apr_file_remove(storename, slotmem->gpool); + rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, + APR_OS_DEFAULT, slotmem->gpool); + } + if (rv != APR_SUCCESS) { + return; + } + if (AP_SLOTMEM_IS_CLEARINUSE(slotmem)) { + slotmem_clearinuse(slotmem); + } + nbytes = (slotmem->desc->size * slotmem->desc->num) + + (slotmem->desc->num * sizeof(char)) + AP_UNSIGNEDINT_OFFSET; + apr_md5(digest, slotmem->persist, nbytes); + rv = apr_file_write_full(fp, slotmem->persist, nbytes, NULL); + if (rv == APR_SUCCESS) { + rv = apr_file_write_full(fp, digest, APR_MD5_DIGESTSIZE, NULL); + } + if (rv == APR_SUCCESS) { + rv = apr_file_write_full(fp, slotmem->desc, AP_SLOTMEM_OFFSET, + NULL); + } + apr_file_close(fp); + if (rv != APR_SUCCESS) { + apr_file_remove(storename, slotmem->gpool); + } + } +} + +static apr_status_t restore_slotmem(sharedslotdesc_t *desc, + const char *storename, apr_size_t size, + apr_pool_t *pool) +{ + apr_file_t *fp; + apr_status_t rv = APR_ENOTIMPL; + void *ptr = (char *)desc + AP_SLOTMEM_OFFSET; + apr_size_t nbytes = size - AP_SLOTMEM_OFFSET; + unsigned char digest[APR_MD5_DIGESTSIZE]; + unsigned char digest2[APR_MD5_DIGESTSIZE]; + char desc_buf[AP_SLOTMEM_OFFSET]; + + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02335) + "restoring %s", storename); + + if (storename) { + rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT, + pool); + if (rv == APR_SUCCESS) { + rv = apr_file_read_full(fp, ptr, nbytes, NULL); + if (rv == APR_SUCCESS || rv == APR_EOF) { + /* + * if at EOF, don't bother checking md5 + * - backwards compatibility + * */ + if (apr_file_eof(fp) != APR_EOF) { + rv = apr_file_read_full(fp, digest, APR_MD5_DIGESTSIZE, NULL); + if (rv == APR_SUCCESS || rv == APR_EOF) { + apr_md5(digest2, ptr, nbytes); + if (memcmp(digest, digest2, APR_MD5_DIGESTSIZE)) { + rv = APR_EMISMATCH; + } + /* + * if at EOF, don't bother checking desc + * - backwards compatibility + * */ + else if (apr_file_eof(fp) != APR_EOF) { + rv = apr_file_read_full(fp, desc_buf, sizeof(desc_buf), NULL); + if (rv == APR_SUCCESS || rv == APR_EOF) { + if (memcmp(desc, desc_buf, sizeof(desc_buf))) { + rv = APR_EMISMATCH; + } + else { + rv = APR_SUCCESS; + } + } + else { + rv = APR_INCOMPLETE; + } + } + else { + rv = APR_EOF; + } + } + else { + rv = APR_INCOMPLETE; + } + } + else { + rv = APR_EOF; + } + if (rv == APR_EMISMATCH) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(02551) + "persisted slotmem md5/desc mismatch"); + } + else if (rv == APR_EOF) { + ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, APLOGNO(02552) + "persisted slotmem at EOF... bypassing md5/desc match check " + "(old persist file?)"); + rv = APR_SUCCESS; + } + } + else { + rv = APR_INCOMPLETE; + } + if (rv == APR_INCOMPLETE) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(02553) + "persisted slotmem read had unexpected size"); + } + apr_file_close(fp); + } + } + return rv; +} + +/* + * Whether the module is called from a MPM that re-enter main() and + * pre/post_config phases. + */ +static APR_INLINE int is_child_process(void) +{ +#ifdef WIN32 + return getenv("AP_PARENT_PID") != NULL; +#else + return 0; +#endif +} + +static apr_status_t cleanup_slotmem(void *param) +{ + int is_child = is_child_process(); + ap_slotmem_instance_t *next = globallistmem; + + while (next) { + if (!is_child && AP_SLOTMEM_IS_PERSIST(next)) { + store_slotmem(next); + } + apr_shm_destroy(next->shm); + apr_shm_remove(next->name, next->gpool); + next = next->next; + } + + globallistmem = NULL; + return APR_SUCCESS; +} + +static apr_status_t slotmem_doall(ap_slotmem_instance_t *mem, + ap_slotmem_callback_fn_t *func, + void *data, apr_pool_t *pool) +{ + unsigned int i; + char *ptr; + char *inuse; + apr_status_t retval = APR_SUCCESS; + + if (!mem) { + return APR_ENOSHMAVAIL; + } + + ptr = (char *)mem->base; + inuse = mem->inuse; + for (i = 0; i < mem->desc->num; i++, inuse++) { + if (!AP_SLOTMEM_IS_PREGRAB(mem) || *inuse) { + retval = func((void *) ptr, data, pool); + if (retval != APR_SUCCESS) + break; + } + ptr += mem->desc->size; + } + 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) +{ + int fbased = 1; + int restored = 0; + char *ptr; + sharedslotdesc_t *desc; + ap_slotmem_instance_t *res; + ap_slotmem_instance_t *next = globallistmem; + const char *fname, *pname = NULL; + apr_shm_t *shm; + apr_size_t basesize = (item_size * item_num); + apr_size_t size = AP_SLOTMEM_OFFSET + AP_UNSIGNEDINT_OFFSET + + (item_num * sizeof(char)) + basesize; + int persist = (type & AP_SLOTMEM_TYPE_PERSIST) != 0; + apr_status_t rv; + + *new = NULL; + if (gpool == NULL) { + return APR_ENOSHMAVAIL; + } + if (slotmem_filenames(pool, name, &fname, persist ? &pname : NULL)) { + /* first try to attach to existing slotmem */ + if (next) { + for (;;) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02603) + "create found %s in global list", fname); + return APR_SUCCESS; + } + if (!next->next) { + break; + } + next = next->next; + } + } + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02602) + "create didn't find %s in global list", fname); + } + else { + fbased = 0; + fname = "none"; + } + + /* first try to attach to existing shared memory */ + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02300) + "create %s: %"APR_SIZE_T_FMT"/%u", fname, item_size, + item_num); + + { + /* For MPMs that run pre/post_config() phases in both the parent + * and children processes (e.g. winnt), SHMs created by the + * parent exist in the children already; attach them. + */ + if (fbased) { + if (is_child_process()) { + rv = apr_shm_attach(&shm, fname, gpool); + } + else { + apr_shm_remove(fname, pool); + rv = apr_shm_create(&shm, size, fname, gpool); + } + } + else { + rv = apr_shm_create(&shm, size, NULL, gpool); + } + ap_log_error(APLOG_MARK, rv == APR_SUCCESS ? APLOG_DEBUG : APLOG_ERR, + rv, ap_server_conf, APLOGNO(02611) + "create: apr_shm_%s(%s) %s", + fbased && is_child_process() ? "attach" : "create", + fname, rv == APR_SUCCESS ? "succeeded" : "failed"); + if (rv != APR_SUCCESS) { + return rv; + } + + desc = (sharedslotdesc_t *)apr_shm_baseaddr_get(shm); + memset(desc, 0, size); + desc->size = item_size; + desc->num = item_num; + desc->type = type; + + /* + * TODO: Error check the below... What error makes + * sense if the restore fails? Any? + * For now, we continue with a fresh new slotmem, + * but NOTICE in the log. + */ + if (persist) { + rv = restore_slotmem(desc, pname, size, pool); + if (rv == APR_SUCCESS) { + restored = 1; + } + else { + /* just in case, re-zero */ + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + APLOGNO(02554) "could not restore %s", fname); + memset((char *)desc + AP_SLOTMEM_OFFSET, 0, + size - AP_SLOTMEM_OFFSET); + } + } + } + + ptr = (char *)desc + AP_SLOTMEM_OFFSET; + + /* For the chained slotmem stuff */ + res = apr_pcalloc(gpool, sizeof(ap_slotmem_instance_t)); + res->name = apr_pstrdup(gpool, fname); + res->pname = apr_pstrdup(gpool, pname); + res->fbased = fbased; + res->shm = shm; + res->persist = (void *)ptr; + res->num_free = (unsigned int *)ptr; + ptr += AP_UNSIGNEDINT_OFFSET; + if (!restored) { + *res->num_free = item_num; + } + res->base = (void *)ptr; + res->desc = desc; + res->gpool = gpool; + res->next = NULL; + res->inuse = ptr + basesize; + if (fbased) { + if (globallistmem == NULL) { + globallistmem = res; + } + else { + next->next = res; + } + } + + *new = res; + 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) +{ + char *ptr; + ap_slotmem_instance_t *res; + ap_slotmem_instance_t *next = globallistmem; + sharedslotdesc_t *desc; + const char *fname; + apr_shm_t *shm; + apr_status_t rv; + + if (gpool == NULL) { + return APR_ENOSHMAVAIL; + } + if (!slotmem_filenames(pool, name, &fname, NULL)) { + return APR_ENOSHMAVAIL; + } + + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02301) + "attach looking for %s", fname); + + /* first try to attach to existing slotmem */ + if (next) { + for (;;) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + *item_size = next->desc->size; + *item_num = next->desc->num; + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + APLOGNO(02302) + "attach found %s: %"APR_SIZE_T_FMT"/%u", fname, + *item_size, *item_num); + return APR_SUCCESS; + } + if (!next->next) { + break; + } + next = next->next; + } + } + + /* next try to attach to existing shared memory */ + rv = apr_shm_attach(&shm, fname, gpool); + if (rv != APR_SUCCESS) { + return rv; + } + + /* Read the description of the slotmem */ + desc = (sharedslotdesc_t *)apr_shm_baseaddr_get(shm); + ptr = (char *)desc + AP_SLOTMEM_OFFSET; + + /* For the chained slotmem stuff */ + res = apr_pcalloc(gpool, sizeof(ap_slotmem_instance_t)); + res->name = apr_pstrdup(gpool, fname); + res->fbased = 1; + res->shm = shm; + res->persist = (void *)ptr; + res->num_free = (unsigned int *)ptr; + ptr += AP_UNSIGNEDINT_OFFSET; + res->base = (void *)ptr; + res->desc = desc; + res->gpool = gpool; + res->inuse = ptr + (desc->size * desc->num); + res->next = NULL; + + *new = res; + *item_size = desc->size; + *item_num = desc->num; + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + APLOGNO(02303) + "attach found %s: %"APR_SIZE_T_FMT"/%u", fname, + *item_size, *item_num); + return APR_SUCCESS; +} + +static apr_status_t slotmem_dptr(ap_slotmem_instance_t *slot, + unsigned int id, void **mem) +{ + char *ptr; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + if (id >= slot->desc->num) { + return APR_EINVAL; + } + + ptr = (char *)slot->base + slot->desc->size * id; + if (!ptr) { + return APR_ENOSHMAVAIL; + } + *mem = (void *)ptr; + 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; + apr_status_t ret; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse + id; + if (id >= slot->desc->num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { + return APR_NOTFOUND; + } + ret = slotmem_dptr(slot, id, &ptr); + if (ret != APR_SUCCESS) { + return ret; + } + *inuse = 1; + memcpy(dest, ptr, dest_len); /* bounds check? */ + 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; + apr_status_t ret; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse + id; + if (id >= slot->desc->num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { + return APR_NOTFOUND; + } + ret = slotmem_dptr(slot, id, &ptr); + if (ret != APR_SUCCESS) { + return ret; + } + *inuse=1; + memcpy(ptr, src, src_len); /* bounds check? */ + return APR_SUCCESS; +} + +static unsigned int slotmem_num_slots(ap_slotmem_instance_t *slot) +{ + return slot->desc->num; +} + +static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) +{ + if (AP_SLOTMEM_IS_PREGRAB(slot)) + return *slot->num_free; + else { + unsigned int i, counter=0; + char *inuse = slot->inuse; + for (i=0; i<slot->desc->num; i++, inuse++) { + if (!*inuse) + counter++; + } + return counter; + } +} + +static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) +{ + return slot->desc->size; +} + +static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id) +{ + unsigned int i; + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse; + + for (i = 0; i < slot->desc->num; i++, inuse++) { + if (!*inuse) { + break; + } + } + if (i >= slot->desc->num) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02293) + "slotmem(%s) grab failed. Num %u/num_free %u", + slot->name, slotmem_num_slots(slot), + slotmem_num_free_slots(slot)); + return APR_EINVAL; + } + *inuse = 1; + *id = i; + (*slot->num_free)--; + return APR_SUCCESS; +} + +static apr_status_t slotmem_fgrab(ap_slotmem_instance_t *slot, unsigned int id) +{ + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + if (id >= slot->desc->num) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02397) + "slotmem(%s) fgrab failed. Num %u/num_free %u", + slot->name, slotmem_num_slots(slot), + slotmem_num_free_slots(slot)); + return APR_EINVAL; + } + inuse = slot->inuse + id; + + if (!*inuse) { + *inuse = 1; + (*slot->num_free)--; + } + return APR_SUCCESS; +} + +static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, + unsigned int id) +{ + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + inuse = slot->inuse; + + if (id >= slot->desc->num || !inuse[id] ) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02294) + "slotmem(%s) release failed. Num %u/inuse[%u] %d", + slot->name, slotmem_num_slots(slot), + id, (int)inuse[id]); + if (id >= slot->desc->num) { + return APR_EINVAL; + } else { + return APR_NOTFOUND; + } + } + inuse[id] = 0; + (*slot->num_free)++; + return APR_SUCCESS; +} + +static const ap_slotmem_provider_t storage = { + "sharedmem", + &slotmem_doall, + &slotmem_create, + &slotmem_attach, + &slotmem_dptr, + &slotmem_get, + &slotmem_put, + &slotmem_num_slots, + &slotmem_num_free_slots, + &slotmem_slot_size, + &slotmem_grab, + &slotmem_release, + &slotmem_fgrab +}; + +/* make the storage usable from outside */ +static const ap_slotmem_provider_t *slotmem_shm_getstorage(void) +{ + return (&storage); +} + +/* + * Make sure the shared memory is cleaned + */ +static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, + server_rec *s) +{ + apr_pool_cleanup_register(p, NULL, cleanup_slotmem, apr_pool_cleanup_null); + return OK; +} + +static int pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) +{ + gpool = p; + globallistmem = NULL; + return OK; +} + +static void ap_slotmem_shm_register_hook(apr_pool_t *p) +{ + const ap_slotmem_provider_t *storage = slotmem_shm_getstorage(); + ap_register_provider(p, AP_SLOTMEM_PROVIDER_GROUP, "shm", + AP_SLOTMEM_PROVIDER_VERSION, storage); + ap_hook_post_config(post_config, NULL, NULL, APR_HOOK_LAST); + ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE); +} + +AP_DECLARE_MODULE(slotmem_shm) = { + STANDARD20_MODULE_STUFF, + 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 */ +}; diff --git a/modules/slotmem/mod_slotmem_shm.dep b/modules/slotmem/mod_slotmem_shm.dep new file mode 100644 index 0000000..e3320b8 --- /dev/null +++ b/modules/slotmem/mod_slotmem_shm.dep @@ -0,0 +1,57 @@ +# Microsoft Developer Studio Generated Dependency File, included by mod_slotmem_shm.mak + +..\..\build\win32\httpd.rc : \ + "..\..\include\ap_release.h"\ + + +.\mod_slotmem_shm.c : \ + "..\..\include\ap_config.h"\ + "..\..\include\ap_config_layout.h"\ + "..\..\include\ap_hooks.h"\ + "..\..\include\ap_mmn.h"\ + "..\..\include\ap_mpm.h"\ + "..\..\include\ap_provider.h"\ + "..\..\include\ap_regex.h"\ + "..\..\include\ap_release.h"\ + "..\..\include\ap_slotmem.h"\ + "..\..\include\apache_noprobes.h"\ + "..\..\include\http_config.h"\ + "..\..\include\http_log.h"\ + "..\..\include\http_main.h"\ + "..\..\include\httpd.h"\ + "..\..\include\os.h"\ + "..\..\include\scoreboard.h"\ + "..\..\include\util_cfgtree.h"\ + "..\..\srclib\apr-util\include\apr_buckets.h"\ + "..\..\srclib\apr-util\include\apr_hooks.h"\ + "..\..\srclib\apr-util\include\apr_md5.h"\ + "..\..\srclib\apr-util\include\apr_optional.h"\ + "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ + "..\..\srclib\apr-util\include\apr_uri.h"\ + "..\..\srclib\apr-util\include\apr_xlate.h"\ + "..\..\srclib\apr-util\include\apu.h"\ + "..\..\srclib\apr\include\apr.h"\ + "..\..\srclib\apr\include\apr_allocator.h"\ + "..\..\srclib\apr\include\apr_dso.h"\ + "..\..\srclib\apr\include\apr_errno.h"\ + "..\..\srclib\apr\include\apr_file_info.h"\ + "..\..\srclib\apr\include\apr_file_io.h"\ + "..\..\srclib\apr\include\apr_general.h"\ + "..\..\srclib\apr\include\apr_global_mutex.h"\ + "..\..\srclib\apr\include\apr_inherit.h"\ + "..\..\srclib\apr\include\apr_mmap.h"\ + "..\..\srclib\apr\include\apr_network_io.h"\ + "..\..\srclib\apr\include\apr_poll.h"\ + "..\..\srclib\apr\include\apr_pools.h"\ + "..\..\srclib\apr\include\apr_portable.h"\ + "..\..\srclib\apr\include\apr_proc_mutex.h"\ + "..\..\srclib\apr\include\apr_ring.h"\ + "..\..\srclib\apr\include\apr_shm.h"\ + "..\..\srclib\apr\include\apr_strings.h"\ + "..\..\srclib\apr\include\apr_tables.h"\ + "..\..\srclib\apr\include\apr_thread_mutex.h"\ + "..\..\srclib\apr\include\apr_thread_proc.h"\ + "..\..\srclib\apr\include\apr_time.h"\ + "..\..\srclib\apr\include\apr_user.h"\ + "..\..\srclib\apr\include\apr_want.h"\ + diff --git a/modules/slotmem/mod_slotmem_shm.dsp b/modules/slotmem/mod_slotmem_shm.dsp new file mode 100644 index 0000000..615ddd4 --- /dev/null +++ b/modules/slotmem/mod_slotmem_shm.dsp @@ -0,0 +1,111 @@ +# Microsoft Developer Studio Project File - Name="mod_slotmem_shm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=mod_slotmem_shm - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "mod_slotmem_shm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mod_slotmem_shm.mak" CFG="mod_slotmem_shm - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_slotmem_shm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_slotmem_shm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_slotmem_shm_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /fo"Release/mod_slotmem_shm.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_slotmem_shm.so" /d LONG_NAME="slotmem_shm_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_slotmem_shm.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_shm.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_slotmem_shm.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_shm.so /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\mod_slotmem_shm.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_slotmem_shm_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /fo"Debug/mod_slotmem_shm.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_slotmem_shm.so" /d LONG_NAME="slotmem_shm_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_slotmem_shm.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_shm.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_slotmem_shm.so" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_shm.so +# Begin Special Build Tool +TargetPath=.\Debug\mod_slotmem_shm.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "mod_slotmem_shm - Win32 Release" +# Name "mod_slotmem_shm - Win32 Debug" +# Begin Source File + +SOURCE=.\mod_slotmem_shm.c +# End Source File +# Begin Source File + +SOURCE=..\..\build\win32\httpd.rc +# End Source File +# End Target +# End Project diff --git a/modules/slotmem/mod_slotmem_shm.mak b/modules/slotmem/mod_slotmem_shm.mak new file mode 100644 index 0000000..e7e64b8 --- /dev/null +++ b/modules/slotmem/mod_slotmem_shm.mak @@ -0,0 +1,353 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on mod_slotmem_shm.dsp +!IF "$(CFG)" == "" +CFG=mod_slotmem_shm - Win32 Release +!MESSAGE No configuration specified. Defaulting to mod_slotmem_shm - Win32 Release. +!ENDIF + +!IF "$(CFG)" != "mod_slotmem_shm - Win32 Release" && "$(CFG)" != "mod_slotmem_shm - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mod_slotmem_shm.mak" CFG="mod_slotmem_shm - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_slotmem_shm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_slotmem_shm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_slotmem_shm.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_slotmem_shm.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_slotmem_shm.obj" + -@erase "$(INTDIR)\mod_slotmem_shm.res" + -@erase "$(INTDIR)\mod_slotmem_shm_src.idb" + -@erase "$(INTDIR)\mod_slotmem_shm_src.pdb" + -@erase "$(OUTDIR)\mod_slotmem_shm.exp" + -@erase "$(OUTDIR)\mod_slotmem_shm.lib" + -@erase "$(OUTDIR)\mod_slotmem_shm.pdb" + -@erase "$(OUTDIR)\mod_slotmem_shm.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_slotmem_shm_src" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_slotmem_shm.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_slotmem_shm.so" /d LONG_NAME="slotmem_shm_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_slotmem_shm.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_slotmem_shm.pdb" /debug /out:"$(OUTDIR)\mod_slotmem_shm.so" /implib:"$(OUTDIR)\mod_slotmem_shm.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_shm.so /opt:ref +LINK32_OBJS= \ + "$(INTDIR)\mod_slotmem_shm.obj" \ + "$(INTDIR)\mod_slotmem_shm.res" \ + "..\..\srclib\apr\Release\libapr-1.lib" \ + "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ + "..\..\Release\libhttpd.lib" + +"$(OUTDIR)\mod_slotmem_shm.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Release\mod_slotmem_shm.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_slotmem_shm.so" + if exist .\Release\mod_slotmem_shm.so.manifest mt.exe -manifest .\Release\mod_slotmem_shm.so.manifest -outputresource:.\Release\mod_slotmem_shm.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ELSEIF "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_slotmem_shm.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_slotmem_shm.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_slotmem_shm.obj" + -@erase "$(INTDIR)\mod_slotmem_shm.res" + -@erase "$(INTDIR)\mod_slotmem_shm_src.idb" + -@erase "$(INTDIR)\mod_slotmem_shm_src.pdb" + -@erase "$(OUTDIR)\mod_slotmem_shm.exp" + -@erase "$(OUTDIR)\mod_slotmem_shm.lib" + -@erase "$(OUTDIR)\mod_slotmem_shm.pdb" + -@erase "$(OUTDIR)\mod_slotmem_shm.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_slotmem_shm_src" /FD /EHsc /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_slotmem_shm.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_slotmem_shm.so" /d LONG_NAME="slotmem_shm_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_slotmem_shm.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_slotmem_shm.pdb" /debug /out:"$(OUTDIR)\mod_slotmem_shm.so" /implib:"$(OUTDIR)\mod_slotmem_shm.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_slotmem_shm.so +LINK32_OBJS= \ + "$(INTDIR)\mod_slotmem_shm.obj" \ + "$(INTDIR)\mod_slotmem_shm.res" \ + "..\..\srclib\apr\Debug\libapr-1.lib" \ + "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ + "..\..\Debug\libhttpd.lib" + +"$(OUTDIR)\mod_slotmem_shm.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Debug\mod_slotmem_shm.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_slotmem_shm.so" + if exist .\Debug\mod_slotmem_shm.so.manifest mt.exe -manifest .\Debug\mod_slotmem_shm.so.manifest -outputresource:.\Debug\mod_slotmem_shm.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("mod_slotmem_shm.dep") +!INCLUDE "mod_slotmem_shm.dep" +!ELSE +!MESSAGE Warning: cannot find "mod_slotmem_shm.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" || "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" + +"libapr - Win32 Release" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" + cd "..\..\modules\slotmem" + +"libapr - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ELSEIF "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + +"libapr - Win32 Debug" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" + cd "..\..\modules\slotmem" + +"libapr - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ENDIF + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" + +"libaprutil - Win32 Release" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" + cd "..\..\modules\slotmem" + +"libaprutil - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ELSEIF "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + +"libaprutil - Win32 Debug" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" + cd "..\..\modules\slotmem" + +"libaprutil - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\slotmem" + +!ENDIF + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" + +"libhttpd - Win32 Release" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" + cd ".\modules\slotmem" + +"libhttpd - Win32 ReleaseCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN + cd ".\modules\slotmem" + +!ELSEIF "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + +"libhttpd - Win32 Debug" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" + cd ".\modules\slotmem" + +"libhttpd - Win32 DebugCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN + cd ".\modules\slotmem" + +!ENDIF + +SOURCE=..\..\build\win32\httpd.rc + +!IF "$(CFG)" == "mod_slotmem_shm - Win32 Release" + + +"$(INTDIR)\mod_slotmem_shm.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_slotmem_shm.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "NDEBUG" /d BIN_NAME="mod_slotmem_shm.so" /d LONG_NAME="slotmem_shm_module for Apache" $(SOURCE) + + +!ELSEIF "$(CFG)" == "mod_slotmem_shm - Win32 Debug" + + +"$(INTDIR)\mod_slotmem_shm.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_slotmem_shm.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "_DEBUG" /d BIN_NAME="mod_slotmem_shm.so" /d LONG_NAME="slotmem_shm_module for Apache" $(SOURCE) + + +!ENDIF + +SOURCE=.\mod_slotmem_shm.c + +"$(INTDIR)\mod_slotmem_shm.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + |