Apache HTTPD
shm.c
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#include "apr_general.h"
18#include "apr_shm.h"
19#include "apr_errno.h"
20#include "apr_lib.h"
21#include "apr_strings.h"
22#include "apr_portable.h"
23
24struct apr_shm_t {
26 void *memblock;
27};
28
31 const char *filename,
33{
34 int rc;
36 char *name = NULL;
38
39 newm->pool = pool;
40
41 if (filename) {
42 name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
43 }
44
45 if (name == NULL) {
47 }
48
49 rc = DosAllocSharedMem(&(newm->memblock), name, reqsize, flags);
50
51 if (rc) {
52 return APR_OS2_STATUS(rc);
53 }
54
55 *m = newm;
56 return APR_SUCCESS;
57}
58
61 const char *filename,
64{
66}
67
69{
70 DosFreeMem(m->memblock);
71 return APR_SUCCESS;
72}
73
76{
77 return APR_ENOTIMPL;
78}
79
81{
82 return APR_ENOTIMPL;
83}
84
86 const char *filename,
88{
89 int rc;
91 char *name = NULL;
93
94 newm->pool = pool;
95 name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
96
97 rc = DosGetNamedSharedMem(&(newm->memblock), name, flags);
98
99 if (rc) {
100 return APR_FROM_OS_ERROR(rc);
101 }
102
103 *m = newm;
104 return APR_SUCCESS;
105}
106
108 const char *filename,
111{
112 return apr_shm_attach(m, filename, pool);
113}
114
116{
117 int rc = 0;
118
119 if (m->memblock) {
120 rc = DosFreeMem(m->memblock);
121 }
122
123 return APR_FROM_OS_ERROR(rc);
124}
125
127{
128 return m->memblock;
129}
130
132{
133 ULONG flags, size = 0x1000000;
134 DosQueryMem(m->memblock, &size, &flags);
135 return size;
136}
137
139
141
143 apr_shm_t *shm)
144{
145 *osshm = shm->memblock;
146 return APR_SUCCESS;
147}
148
152{
153 int rc;
156
157 newm->pool = pool;
158
159 rc = DosGetSharedMem(&(newm->memblock), flags);
160
161 if (rc) {
162 return APR_FROM_OS_ERROR(rc);
163 }
164
165 *m = newm;
166 return APR_SUCCESS;
167}
168
APR Error Codes.
APR Miscellaneous library routines.
APR general purpose library routines.
APR Portability Routines.
APR Shared Memory Routines.
APR Strings library.
#define APR_ENOTIMPL
Definition apr_errno.h:476
const char apr_ssize_t int flags
Definition apr_encode.h:168
apr_redis_t * rc
Definition apr_redis.h:173
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
#define APR_FROM_OS_ERROR(e)
Definition apr_errno.h:1214
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
#define APR_PERMS_SET_ENOTIMPL(type)
#define APR_POOL_IMPLEMENT_ACCESSOR(type)
Definition apr_pools.h:91
void * apr_os_shm_t
apr_os_shm_t * osshm
apr_shm_t * shm
apr_size_t const char * filename
Definition apr_shm.h:72
apr_size_t reqsize
Definition apr_shm.h:71
const void * m
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
char * name
void * memblock
Definition shm.c:29
apr_pool_t * pool