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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
* _ __ ___ ___ __| | ___ ___| | mod_ssl
19
* | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
20
* | | | | | | (_) | (_| | \__ \__ \ |
21
* |_| |_| |_|\___/ \__,_|___|___/___/_|
24
* Semaphore for Mutual Exclusion
26
/* ``Real programmers confuse
27
Christmas and Halloween
28
because DEC 25 = OCT 31.''
31
#include "ssl_private.h"
33
#ifdef AP_NEED_SET_MUTEX_PERMS
37
int ssl_mutex_init(server_rec *s, apr_pool_t *p)
39
SSLModConfigRec *mc = myModConfig(s);
42
if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
48
if ((rv = apr_global_mutex_create(&mc->pMutex, mc->szMutexFile,
49
mc->nMutexMech, s->process->pool))
52
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
53
"Cannot create SSLMutex with file `%s'",
56
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
57
"Cannot create SSLMutex");
61
#ifdef AP_NEED_SET_MUTEX_PERMS
62
rv = unixd_set_global_mutex_perms(mc->pMutex);
63
if (rv != APR_SUCCESS) {
64
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
65
"Could not set permissions on ssl_mutex; check User "
66
"and Group directives");
73
int ssl_mutex_reinit(server_rec *s, apr_pool_t *p)
75
SSLModConfigRec *mc = myModConfig(s);
78
if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
81
if ((rv = apr_global_mutex_child_init(&mc->pMutex,
82
mc->szMutexFile, p)) != APR_SUCCESS) {
84
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
85
"Cannot reinit SSLMutex with file `%s'",
88
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
89
"Cannot reinit SSLMutex");
95
int ssl_mutex_on(server_rec *s)
97
SSLModConfigRec *mc = myModConfig(s);
100
if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
102
if ((rv = apr_global_mutex_lock(mc->pMutex)) != APR_SUCCESS) {
103
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
104
"Failed to acquire SSL session cache lock");
110
int ssl_mutex_off(server_rec *s)
112
SSLModConfigRec *mc = myModConfig(s);
115
if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
117
if ((rv = apr_global_mutex_unlock(mc->pMutex)) != APR_SUCCESS) {
118
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
119
"Failed to release SSL session cache lock");