Apache HTTPD
thread_rwlock.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_arch_thread_rwlock.h"
18#include "apr_private.h"
19
20#if APR_HAS_THREADS
21
22#ifdef HAVE_PTHREAD_RWLOCKS
23
24/* The rwlock must be initialized but not locked by any thread when
25 * cleanup is called. */
27{
30
32#ifdef HAVE_ZOS_PTHREADS
33 if (stat) {
34 stat = errno;
35 }
36#endif
37 return stat;
38}
39
42{
45
47 new_rwlock->pool = pool;
48
49 if ((stat = pthread_rwlock_init(&new_rwlock->rwlock, NULL))) {
50#ifdef HAVE_ZOS_PTHREADS
51 stat = errno;
52#endif
53 return stat;
54 }
55
59
60 *rwlock = new_rwlock;
61 return APR_SUCCESS;
62}
63
65{
67
69#ifdef HAVE_ZOS_PTHREADS
70 if (stat) {
71 stat = errno;
72 }
73#endif
74 return stat;
75}
76
78{
80
82#ifdef HAVE_ZOS_PTHREADS
83 if (stat) {
84 stat = errno;
85 }
86#endif
87 /* Normalize the return code. */
88 if (stat == EBUSY)
90 return stat;
91}
92
94{
96
98#ifdef HAVE_ZOS_PTHREADS
99 if (stat) {
100 stat = errno;
101 }
102#endif
103 return stat;
104}
105
107{
109
111#ifdef HAVE_ZOS_PTHREADS
112 if (stat) {
113 stat = errno;
114 }
115#endif
116 /* Normalize the return code. */
117 if (stat == EBUSY)
118 stat = APR_EBUSY;
119 return stat;
120}
121
123{
125
127#ifdef HAVE_ZOS_PTHREADS
128 if (stat) {
129 stat = errno;
130 }
131#endif
132 return stat;
133}
134
136{
137 return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup);
138}
139
140#else /* HAVE_PTHREAD_RWLOCKS */
141
144{
145 return APR_ENOTIMPL;
146}
147
149{
150 return APR_ENOTIMPL;
151}
152
154{
155 return APR_ENOTIMPL;
156}
157
159{
160 return APR_ENOTIMPL;
161}
162
164{
165 return APR_ENOTIMPL;
166}
167
169{
170 return APR_ENOTIMPL;
171}
172
174{
175 return APR_ENOTIMPL;
176}
177
178#endif /* HAVE_PTHREAD_RWLOCKS */
180
181#endif /* APR_HAS_THREADS */
#define APR_ENOTIMPL
Definition apr_errno.h:476
#define APR_EBUSY
Definition apr_errno.h:480
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_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
void * data
#define APR_POOL_IMPLEMENT_ACCESSOR(type)
Definition apr_pools.h:91
return NULL
Definition mod_so.c:359
static apr_status_t thread_rwlock_cleanup(void *data)
apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock)