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.''
32 #if !defined(OS2) && !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
34 #define MOD_SSL_SET_MUTEX_PERMS /* XXX Apache should define something */
37 int ssl_mutex_init(server_rec *s, apr_pool_t *p)
39 SSLModConfigRec *mc = myModConfig(s);
42 if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
45 if ((rv = apr_global_mutex_create(&mc->pMutex, mc->szMutexFile,
46 mc->nMutexMech, p)) != APR_SUCCESS) {
48 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
49 "Cannot create SSLMutex with file `%s'",
52 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
53 "Cannot create SSLMutex");
57 #ifdef MOD_SSL_SET_MUTEX_PERMS
58 rv = unixd_set_global_mutex_perms(mc->pMutex);
59 if (rv != APR_SUCCESS) {
60 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
61 "Could not set permissions on ssl_mutex; check User "
62 "and Group directives");
69 int ssl_mutex_reinit(server_rec *s, apr_pool_t *p)
71 SSLModConfigRec *mc = myModConfig(s);
74 if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
77 if ((rv = apr_global_mutex_child_init(&mc->pMutex,
78 mc->szMutexFile, p)) != APR_SUCCESS) {
80 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
81 "Cannot reinit SSLMutex with file `%s'",
84 ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
85 "Cannot reinit SSLMutex");
91 int ssl_mutex_on(server_rec *s)
93 SSLModConfigRec *mc = myModConfig(s);
96 if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
98 if ((rv = apr_global_mutex_lock(mc->pMutex)) != APR_SUCCESS) {
99 ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
100 "Failed to acquire global mutex lock");
106 int ssl_mutex_off(server_rec *s)
108 SSLModConfigRec *mc = myModConfig(s);
111 if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
113 if ((rv = apr_global_mutex_unlock(mc->pMutex)) != APR_SUCCESS) {
114 ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
115 "Failed to release global mutex lock");