2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_slotmem_shm.xml.meta">
25 <name>mod_slotmem_shm</name>
26 <description>Slot-based shared memory provider.</description>
27 <status>Extension</status>
28 <sourcefile>mod_slotmem_shm.c</sourcefile>
29 <identifier>slotmem_shm_module</identifier>
32 <p><code>mod_slotmem_shm</code> is a memory provider which
33 provides for creation and access to a shared memory segment
34 in which the datasets are organized in "slots."
37 <p>All shared memory is cleared and cleaned with each
38 restart, whether graceful or not. The data itself is
39 stored and restored within a file noted by the <code>name</code>
40 parameter in the <code>create</code> and <code>attach</code>
41 calls. If not specified with an absolute path, the file will be
42 created relative to the path specified by the
43 <directive module="core">DefaultRuntimeDir</directive> directive.
46 <p><code>mod_slotmem_shm</code> provides the following API functions:
50 <dt>apr_status_t doall(ap_slotmem_instance_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)</dt>
51 <dd>call the callback on all worker slots</dd>
53 <dt>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)</dt>
54 <dd>create a new slotmem with each item size is item_size. <code>name</code> is used to generate a filename for the persistent store of
55 the shared memory if configured. Values are:
57 <dt><code>"none"</code></dt>
58 <dd><code>Anonymous shared memory and no persistent store</code></dd>
59 <dt><code>"file-name"</code></dt>
60 <dd><code>[DefaultRuntimeDir]/file-name</code></dd>
61 <dt><code>"/absolute-file-name"</code></dt>
62 <dd><code>Absolute file name</code></dd>
65 <dt>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)</dt>
66 <dd>attach to an existing slotmem. See <code>create</code> for description of <code>name</code> parameter.</dd>
68 <dt>apr_status_t dptr(ap_slotmem_instance_t *s, unsigned int item_id, void**mem)</dt>
69 <dd>get the direct pointer to the memory associated with this worker slot.</dd>
71 <dt>apr_status_t get(ap_slotmem_instance_t *s, unsigned int item_id, unsigned char *dest, apr_size_t dest_len)</dt>
72 <dd>get/read the memory from this slot to dest</dd>
74 <dt>apr_status_t put(ap_slotmem_instance_t *slot, unsigned int item_id, unsigned char *src, apr_size_t src_len)</dt>
75 <dd>put/write the data from src to this slot</dd>
77 <dt>unsigned int num_slots(ap_slotmem_instance_t *s)</dt>
78 <dd>return the total number of slots in the segment</dd>
80 <dt>apr_size_t slot_size(ap_slotmem_instance_t *s)</dt>
81 <dd>return the total data size, in bytes, of a slot in the segment</dd>
83 <dt>apr_status_t grab(ap_slotmem_instance_t *s, unsigned int *item_id);</dt>
84 <dd>grab or allocate the first free slot and mark as in-use (does not do any data copying)</dd>
86 <dt>apr_status_t fgrab(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
87 <dd>forced grab or allocate the specified slot and mark as in-use (does not do any data copying)</dd>
89 <dt>apr_status_t release(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
90 <dd>release or free a slot and mark as not in-use (does not do any data copying)</dd>