Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ap_slotmem.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SLOTMEM_H
18 #define SLOTMEM_H
19 
20 /* Memory handler for a shared memory divided in slot.
21  */
31 #include "httpd.h"
32 #include "http_config.h"
33 #include "http_log.h"
34 #include "ap_provider.h"
35 
36 #include "apr.h"
37 #include "apr_strings.h"
38 #include "apr_pools.h"
39 #include "apr_shm.h"
40 #include "apr_global_mutex.h"
41 #include "apr_file_io.h"
42 #include "apr_md5.h"
43 
44 #if APR_HAVE_UNISTD_H
45 #include <unistd.h> /* for getpid() */
46 #endif
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 #define AP_SLOTMEM_PROVIDER_GROUP "slotmem"
53 #define AP_SLOTMEM_PROVIDER_VERSION "0"
54 
55 typedef unsigned int ap_slotmem_type_t;
56 
57 /*
58  * Values for ap_slotmem_type_t::
59  *
60  * AP_SLOTMEM_TYPE_PERSIST: For transitory providers, persist
61  * the data on the file-system
62  *
63  * AP_SLOTMEM_TYPE_NOTMPSAFE:
64  *
65  * AP_SLOTMEM_TYPE_PREALLOC: Access to slots require they be grabbed 1st
66  *
67  * AP_SLOTMEM_TYPE_CLEARINUSE: If persisting, clear 'inuse' array before
68  * storing
69  */
70 #define AP_SLOTMEM_TYPE_PERSIST (1 << 0)
71 #define AP_SLOTMEM_TYPE_NOTMPSAFE (1 << 1)
72 #define AP_SLOTMEM_TYPE_PREGRAB (1 << 2)
73 #define AP_SLOTMEM_TYPE_CLEARINUSE (1 << 3)
74 
76 
85 
87  /*
88  * Name of the provider method
89  */
90  const char *name;
111  apr_status_t (* create)(ap_slotmem_instance_t **inst, const char *name, apr_size_t item_size, unsigned int item_num, ap_slotmem_type_t type, apr_pool_t *pool);
122  apr_status_t (* attach)(ap_slotmem_instance_t **inst, const char *name, apr_size_t *item_size, unsigned int *item_num, apr_pool_t *pool);
130  apr_status_t (* dptr)(ap_slotmem_instance_t *s, unsigned int item_id, void**mem);
139  apr_status_t (* get)(ap_slotmem_instance_t *s, unsigned int item_id, unsigned char *dest, apr_size_t dest_len);
148  apr_status_t (* put)(ap_slotmem_instance_t *slot, unsigned int item_id, unsigned char *src, apr_size_t src_len);
175  apr_status_t (* grab)(ap_slotmem_instance_t *s, unsigned int *item_id);
182  apr_status_t (* release)(ap_slotmem_instance_t *s, unsigned int item_id);
189  apr_status_t (* fgrab)(ap_slotmem_instance_t *s, unsigned int item_id);
190 };
191 
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif
199 
apr_status_t(* doall)(ap_slotmem_instance_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
Definition: ap_slotmem.h:99
size_t apr_size_t
Definition: apr.h:375
apr_status_t(* release)(ap_slotmem_instance_t *s, unsigned int item_id)
Definition: ap_slotmem.h:182
struct ap_slotmem_instance_t ap_slotmem_instance_t
Definition: ap_slotmem.h:75
apr_status_t(* grab)(ap_slotmem_instance_t *s, unsigned int *item_id)
Definition: ap_slotmem.h:175
Apache Configuration.
apr_status_t ap_slotmem_callback_fn_t(void *mem, void *data, apr_pool_t *pool)
Definition: ap_slotmem.h:84
apr_size_t(* slot_size)(ap_slotmem_instance_t *s)
Definition: ap_slotmem.h:168
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:556
Apache Provider API.
apr_status_t(* put)(ap_slotmem_instance_t *slot, unsigned int item_id, unsigned char *src, apr_size_t src_len)
Definition: ap_slotmem.h:148
APR File I/O Handling.
apr_status_t(* dptr)(ap_slotmem_instance_t *s, unsigned int item_id, void **mem)
Definition: ap_slotmem.h:130
Apache Logging library.
Definition: ap_slotmem.h:86
APR memory allocation.
APR Global Locking Routines.
HTTP Daemon routines.
int
Definition: mod_proxy.h:617
unsigned int ap_slotmem_type_t
Definition: ap_slotmem.h:55
dav_error * src
Definition: mod_dav.h:186
APR Shared Memory Routines.
APR Platform Definitions.
APR MD5 Routines.
apr_status_t(* attach)(ap_slotmem_instance_t **inst, const char *name, apr_size_t *item_size, unsigned int *item_num, apr_pool_t *pool)
Definition: ap_slotmem.h:122
apr_status_t(* fgrab)(ap_slotmem_instance_t *s, unsigned int item_id)
Definition: ap_slotmem.h:189
APR Strings library.
const char * name
Definition: ap_slotmem.h:90
dav_buffer const void * mem
Definition: mod_dav.h:481
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
apr_status_t(* create)(ap_slotmem_instance_t **inst, const char *name, apr_size_t item_size, unsigned int item_num, ap_slotmem_type_t type, apr_pool_t *pool)
Definition: ap_slotmem.h:111
unsigned int(* num_slots)(ap_slotmem_instance_t *s)
Definition: ap_slotmem.h:154
unsigned int(* num_free_slots)(ap_slotmem_instance_t *s)
Definition: ap_slotmem.h:162