Apache HTTPD
ssl_engine_mutex.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/* _ _
18 * _ __ ___ ___ __| | ___ ___| | mod_ssl
19 * | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
20 * | | | | | | (_) | (_| | \__ \__ \ |
21 * |_| |_| |_|\___/ \__,_|___|___/___/_|
22 * |_____|
23 * ssl_engine_mutex.c
24 * Semaphore for Mutual Exclusion
25 */
26 /* ``Real programmers confuse
27 Christmas and Halloween
28 because DEC 25 = OCT 31.''
29 -- Unknown */
30
31#include "ssl_private.h"
32
34{
36 apr_status_t rv;
37
38 /* A mutex is only needed if a session cache is configured, and
39 * the provider used is not internally multi-process/thread
40 * safe. */
41 if (!mc->sesscache
42 || (mc->sesscache->flags & AP_SOCACHE_FLAG_NOTMPSAFE) == 0) {
43 return TRUE;
44 }
45
46 if (mc->pMutex) {
47 return TRUE;
48 }
49
51 NULL, s, s->process->pool, 0))
52 != APR_SUCCESS) {
53 return FALSE;
54 }
55
56 return TRUE;
57}
58
60{
62 apr_status_t rv;
63 const char *lockfile;
64
65 if (mc->pMutex == NULL || !mc->sesscache
66 || (mc->sesscache->flags & AP_SOCACHE_FLAG_NOTMPSAFE) == 0) {
67 return TRUE;
68 }
69
71 if ((rv = apr_global_mutex_child_init(&mc->pMutex,
73 p)) != APR_SUCCESS) {
74 if (lockfile)
76 "Cannot reinit %s mutex with file `%s'",
78 else
80 "Cannot reinit %s mutex", SSL_CACHE_MUTEX_TYPE);
81 return FALSE;
82 }
83 return TRUE;
84}
85
87{
89 apr_status_t rv;
90
91 if ((rv = apr_global_mutex_lock(mc->pMutex)) != APR_SUCCESS) {
93 "Failed to acquire SSL session cache lock");
94 return FALSE;
95 }
96 return TRUE;
97}
98
100{
102 apr_status_t rv;
103
104 if ((rv = apr_global_mutex_unlock(mc->pMutex)) != APR_SUCCESS) {
106 "Failed to release SSL session cache lock");
107 return FALSE;
108 }
109 return TRUE;
110}
111
#define TRUE
Definition abts.h:38
#define FALSE
Definition abts.h:35
#define APLOGNO(n)
Definition http_log.h:117
#define APLOG_ERR
Definition http_log.h:67
#define ap_log_error
Definition http_log.h:370
#define APLOG_MARK
Definition http_log.h:283
#define APLOG_WARNING
Definition http_log.h:68
apr_status_t ap_global_mutex_create(apr_global_mutex_t **mutex, const char **name, const char *type, const char *instance_id, server_rec *server, apr_pool_t *pool, apr_int32_t options)
Definition util_mutex.c:407
apr_memcache_t * mc
#define AP_SOCACHE_FLAG_NOTMPSAFE
Definition ap_socache.h:46
#define myModConfig(srv)
int ssl_mutex_off(server_rec *s)
#define SSL_CACHE_MUTEX_TYPE
int ssl_mutex_init(server_rec *s, apr_pool_t *p)
int ssl_mutex_reinit(server_rec *s, apr_pool_t *p)
int ssl_mutex_on(server_rec *s)
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
const char * s
Definition apr_strings.h:95
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
Internal interfaces private to mod_ssl.
apr_uint32_t flags
A structure to store information for each virtual server.
Definition httpd.h:1322