mod_slotmem_shm
is a memory provider which
provides for creation and access to a shared memory segment
in which the datasets are organized in "slots."
All shared memory is cleared and cleaned with each
restart, whether graceful or not. The data itself is
stored and restored within a file noted by the name
parameter in the create
and attach
calls.
mod_slotmem_shm
provides the following API functions:
- apr_status_t doall(ap_slotmem_instance_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
- call the callback on all worker slots
- apr_status_t 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)
- create a new slotmem with each item size is item_size.
name
is the filename for the persistent store of
the shared memory. Values are:
"none"
Does not persist shared memory in file.
"anonymous"
$server_root/logs/anonymous.slotmem
":file-name"
$server_root/logs/file-name.slotmem
"absolute-file-name"
$absolute-file-name.slotmem
- apr_status_t attach(ap_slotmem_instance_t **new, const char *name, apr_size_t *item_size, unsigned int *item_num, apr_pool_t *pool)
- attach to an existing slotmem. See
create
for description of name
parameter.
- apr_status_t dptr(ap_slotmem_instance_t *s, unsigned int item_id, void**mem)
- get the direct pointer to the memory associated with this worker slot.
- apr_status_t get(ap_slotmem_instance_t *s, unsigned int item_id, unsigned char *dest, apr_size_t dest_len)
- get/read the memory from this slot to dest
- apr_status_t put(ap_slotmem_instance_t *slot, unsigned int item_id, unsigned char *src, apr_size_t src_len)
- put/write the data from src to this slot
- unsigned int num_slots(ap_slotmem_instance_t *s)
- return the total number of slots in the segment
- apr_size_t slot_size(ap_slotmem_instance_t *s)
- return the total data size, in bytes, of a slot in the segment
- apr_status_t grab(ap_slotmem_instance_t *s, unsigned int item_id);
- grab or allocate a slot and mark as in-use (does not do any data copying)
- apr_status_t release(ap_slotmem_instance_t *s, unsigned int item_id);
- release or free a slot and mark as not in-use (does not do any data copying)