Changeset babdb29 in mod_gnutls for src/gnutls_cache.c


Ignore:
Timestamp:
May 16, 2018, 2:12:08 AM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, debian/master, master, proxy-ticket
Children:
92b5f4d
Parents:
d036f96
Message:

Initialize and clean up the OCSP cache, following session cache patterns

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    rd036f96 rbabdb29  
    3131#include "mod_gnutls.h"
    3232#include "gnutls_config.h"
     33#include "gnutls_ocsp.h"
    3334
    3435#include <ap_socache.h>
     
    414415    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
    415416        ap_get_module_config(s->module_config, &gnutls_module);
    416     ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s,
    417                  "Cleaning up socache '%s:%s'",
    418                  sc->cache->prov->name, sc->cache->config);
    419     sc->cache->prov->destroy(sc->cache->socache, s);
     417    if (sc->cache)
     418    {
     419        ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s,
     420                     "Cleaning up session cache '%s:%s'",
     421                     sc->cache->prov->name, sc->cache->config);
     422        sc->cache->prov->destroy(sc->cache->socache, s);
     423    }
     424    if (sc->ocsp_cache)
     425    {
     426        ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s,
     427                     "Cleaning up OCSP cache '%s:%s'",
     428                     sc->ocsp_cache->prov->name, sc->ocsp_cache->config);
     429        sc->ocsp_cache->prov->destroy(sc->ocsp_cache->socache, s);
     430    }
    420431    return APR_SUCCESS;
    421432}
     
    428439{
    429440    apr_status_t rv = APR_SUCCESS;
     441
     442    /* Initialize the OCSP cache first so it's not skipped if the
     443     * session cache is disabled. */
     444    if (sc->ocsp_cache != NULL)
     445    {
     446        /* TODO: Maybe initialize only if explicitly enabled OR at
     447         * least one (virtual) host has OCSP enabled? */
     448        rv = mgs_cache_inst_init(sc->ocsp_cache, MGS_OCSP_CACHE_NAME,
     449                                 MGS_OCSP_CACHE_MUTEX_NAME, s, pconf);
     450        if (rv != APR_SUCCESS)
     451            return HTTP_INSUFFICIENT_STORAGE;
     452    }
     453
    430454    /* GnuTLSCache was never explicitly set or is disabled: */
    431455    if (sc->cache_enable == GNUTLS_ENABLED_UNSET
     
    450474}
    451475
    452 int mgs_cache_child_init(apr_pool_t * p,
    453                          server_rec * s,
    454                          mgs_srvconf_rec * sc)
     476int mgs_cache_child_init(apr_pool_t *p, server_rec *server,
     477                         mgs_cache_t cache, const char *mutex_name)
    455478{
    456479    /* reinit cache mutex */
    457     const char *lockfile = apr_global_mutex_lockfile(sc->cache->mutex);
    458     apr_status_t rv = apr_global_mutex_child_init(&sc->cache->mutex,
     480    const char *lockfile = apr_global_mutex_lockfile(cache->mutex);
     481    apr_status_t rv = apr_global_mutex_child_init(&cache->mutex,
    459482                                                  lockfile, p);
    460483    if (rv != APR_SUCCESS)
    461         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
    462                      "Failed to reinit mutex '%s'", MGS_CACHE_MUTEX_NAME);
    463 
    464     return 0;
     484        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server,
     485                     "Failed to reinit mutex '%s'", mutex_name);
     486
     487    return rv;
    465488}
    466489
Note: See TracChangeset for help on using the changeset viewer.