Changeset ded2291 in mod_gnutls


Ignore:
Timestamp:
Apr 24, 2018, 1:13:28 PM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
debian/master, master, proxy-ticket
Children:
41f9bcb
Parents:
6bbd378
Message:

Switch generic cache store/fetch function pointers to constant functions

Using socache takes care of the different cache types, so this layer
of abstraction is no longer needed. Add a currently unused mgs_cache_t
parameter to allow for multiple mod_gnutls caches in the future.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    r6bbd378 rded2291  
    112112
    113113
    114 static int socache_store(server_rec *server, gnutls_datum_t key,
    115                          gnutls_datum_t data, apr_time_t expiry)
     114int mgs_cache_store(mgs_cache_t cache __attribute__((unused)),
     115                    server_rec *server, gnutls_datum_t key,
     116                    gnutls_datum_t data, apr_time_t expiry)
    116117{
    117118    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     
    161162    apr_time_t expiry = apr_time_now() + ctxt->sc->cache_timeout;
    162163
    163     return socache_store(ctxt->c->base_server, dbmkey, data, expiry);
     164    return mgs_cache_store(ctxt->sc->cache, ctxt->c->base_server,
     165                           dbmkey, data, expiry);
    164166}
    165167
     
    168170// 4K should be enough for OCSP responses and sessions alike
    169171#define SOCACHE_FETCH_BUF_SIZE 4096
    170 static gnutls_datum_t socache_fetch(server_rec *server, gnutls_datum_t key,
    171                                     apr_pool_t *pool)
     172gnutls_datum_t mgs_cache_fetch(mgs_cache_t cache __attribute__((unused)),
     173                               server_rec *server, gnutls_datum_t key,
     174                               apr_pool_t *pool)
    172175{
    173176    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     
    228231        return data;
    229232
    230     return socache_fetch(ctxt->c->base_server, dbmkey, ctxt->c->pool);
     233    return mgs_cache_fetch(ctxt->sc->cache, ctxt->c->base_server,
     234                           dbmkey, ctxt->c->pool);
    231235}
    232236
     
    310314    else if (sc->cache_type == mgs_cache_shmcb)
    311315        pname = "shmcb";
    312 
    313     sc->cache->store = socache_store;
    314     sc->cache->fetch = socache_fetch;
    315316
    316317    /* Find the right socache provider */
  • src/gnutls_cache.h

    r6bbd378 rded2291  
    8282
    8383/**
    84  * Generic store function for the mod_gnutls object cache.
     84 * Store function for the mod_gnutls object caches.
    8585 *
     86 * @param cache the cache to store the entry in
    8687 * @param s server associated with the cache entry
    8788 * @param key key for the cache entry
     
    9192 * @return `-1` on error, `0` on success
    9293 */
    93 typedef int (*cache_store_func)(server_rec *s, gnutls_datum_t key,
    94                                 gnutls_datum_t data, apr_time_t expiry);
     94int mgs_cache_store(mgs_cache_t cache, server_rec *server, gnutls_datum_t key,
     95                    gnutls_datum_t data, apr_time_t expiry);
     96
    9597/**
    96  * Generic fetch function for the mod_gnutls object cache.
     98 * Fetch function for the mod_gnutls object caches.
    9799 *
    98100 * *Warning*: The `data` element of the returned `gnutls_datum_t` is
    99101 * allocated using `gnutls_malloc()` for compatibility with the GnuTLS
    100102 * session caching API, and must be released using `gnutls_free()`.
     103 *
     104 * @param cache the cache to fetch from
    101105 *
    102106 * @param server server context for the request
     
    109113 * @return the requested cache entry, or `{NULL, 0}`
    110114 */
    111 typedef gnutls_datum_t (*cache_fetch_func)(server_rec *server,
    112                                            gnutls_datum_t key,
    113                                            apr_pool_t *pool);
     115gnutls_datum_t mgs_cache_fetch(mgs_cache_t cache, server_rec *server,
     116                               gnutls_datum_t key, apr_pool_t *pool);
     117
    114118/**
    115119 * Internal cache configuration structure
     
    120124    /** The actual socache instance */
    121125    ap_socache_instance_t *socache;
    122     /** Store function for this cache */
    123     cache_store_func store;
    124     /** Fetch function for this cache */
    125     cache_fetch_func fetch;
    126126    /** Mutex for cache access (used only if the cache type is not
    127127     * thread-safe) */
  • src/gnutls_ocsp.c

    r6bbd378 rded2291  
    723723    }
    724724
    725     int r = sc->cache->store(s, sc->ocsp->fingerprint, resp, expiry);
     725    int r = mgs_cache_store(sc->cache, s, sc->ocsp->fingerprint, resp, expiry);
    726726    /* destroy pool, and original copy of the OCSP response with it */
    727727    apr_pool_destroy(tmp);
     
    763763    apr_time_t expiry = apr_time_now() + timeout;
    764764
    765     int r = sc->cache->store(s, sc->ocsp->fingerprint, dummy, expiry);
     765    int r = mgs_cache_store(sc->cache, s, sc->ocsp->fingerprint, dummy, expiry);
    766766    if (r != 0)
    767767        ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
     
    784784    }
    785785
    786     *ocsp_response = ctxt->sc->cache->fetch(ctxt->c->base_server,
    787                                             ctxt->sc->ocsp->fingerprint,
    788                                             ctxt->c->pool);
     786    *ocsp_response = mgs_cache_fetch(ctxt->sc->cache,
     787                                     ctxt->c->base_server,
     788                                     ctxt->sc->ocsp->fingerprint,
     789                                     ctxt->c->pool);
    789790    if (ocsp_response->size == 0)
    790791    {
     
    821822         * moment there's no good way to integrate that with the
    822823         * Apache Mutex directive. */
    823         *ocsp_response = ctxt->sc->cache->fetch(ctxt->c->base_server,
    824                                                 ctxt->sc->ocsp->fingerprint,
    825                                                 ctxt->c->pool);
     824        *ocsp_response = mgs_cache_fetch(ctxt->sc->cache,
     825                                         ctxt->c->base_server,
     826                                         ctxt->sc->ocsp->fingerprint,
     827                                         ctxt->c->pool);
    826828        if (ocsp_response->size > 0)
    827829        {
     
    851853
    852854    /* retry reading from cache */
    853     *ocsp_response = ctxt->sc->cache->fetch(ctxt->c->base_server,
    854                                             ctxt->sc->ocsp->fingerprint,
    855                                             ctxt->c->pool);
     855    *ocsp_response = mgs_cache_fetch(ctxt->sc->cache,
     856                                     ctxt->c->base_server,
     857                                     ctxt->sc->ocsp->fingerprint,
     858                                     ctxt->c->pool);
    856859    if (ocsp_response->size == 0)
    857860    {
     
    10571060    {
    10581061        const gnutls_datum_t ocsp_response =
    1059             sc->cache->fetch(server, sc->ocsp->fingerprint, pool);
     1062            mgs_cache_fetch(sc->cache, server, sc->ocsp->fingerprint, pool);
    10601063
    10611064        if (ocsp_response.size == 0 ||
Note: See TracChangeset for help on using the changeset viewer.