Changeset a85de63 in mod_gnutls


Ignore:
Timestamp:
Apr 19, 2018, 3:09:04 PM (5 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, debian/master, main, master, proxy-ticket
Children:
103cafa
Parents:
c34a68b
Message:

Make cache_fetch_func work without a connection context

This is necessary to do cache fetches without a client connection,
e.g. while doing asynchronous OCSP updates.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    rc34a68b ra85de63  
    33 *  Copyright 2008 Nikos Mavrogiannopoulos
    44 *  Copyright 2011 Dash Shendy
    5  *  Copyright 2015-2016 Fiona Klute
     5 *  Copyright 2015-2018 Fiona Klute
    66 *
    77 *  Licensed under the Apache License, Version 2.0 (the "License");
     
    326326}
    327327
    328 static gnutls_datum_t mc_cache_fetch_generic(mgs_handle_t *ctxt,
    329                                              gnutls_datum_t key)
     328static gnutls_datum_t mc_cache_fetch_generic(server_rec *server,
     329                                             gnutls_datum_t key,
     330                                             apr_pool_t *pool)
    330331{
    331332    gnutls_datum_t data = {NULL, 0};
    332     const char *hex = apr_pescape_hex(ctxt->c->pool, key.data, key.size, 1);
     333    const char *hex = apr_pescape_hex(pool, key.data, key.size, 1);
    333334    if (hex == NULL)
    334335        return data;
    335336
    336     const char *strkey = apr_psprintf(ctxt->c->pool, MC_TAG "%s", hex);
    337     return mc_cache_fetch(ctxt->c->base_server, strkey, ctxt->c->pool);
     337    const char *strkey = apr_psprintf(pool, MC_TAG "%s", hex);
     338    return mc_cache_fetch(server, strkey, pool);
    338339}
    339340
     
    454455}
    455456
    456 static gnutls_datum_t dbm_cache_fetch(mgs_handle_t *ctxt, gnutls_datum_t key)
    457 {
    458     server_rec *server = ctxt->c->base_server;
    459     apr_pool_t *pool = ctxt->c->pool;
     457
     458
     459static gnutls_datum_t dbm_cache_fetch(server_rec *server, gnutls_datum_t key,
     460                                      apr_pool_t *pool)
     461{
    460462    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
    461463        ap_get_module_config(server->module_config, &gnutls_module);
     
    537539        return data;
    538540
    539     return dbm_cache_fetch(ctxt, dbmkey);
     541    return dbm_cache_fetch(ctxt->c->base_server, dbmkey, ctxt->c->pool);
    540542}
    541543
  • src/gnutls_cache.h

    rc34a68b ra85de63  
    22 *  Copyright 2004-2005 Paul Querna
    33 *  Copyright 2014 Nikos Mavrogiannopoulos
    4  *  Copyright 2015-2016 Fiona Klute
     4 *  Copyright 2015-2018 Fiona Klute
    55 *
    66 *  Licensed under the Apache License, Version 2.0 (the "License");
     
    9797 * session caching API, and must be released using `gnutls_free()`.
    9898 *
    99  * @param ctxt mod_gnutls session context for the request
     99 * @param server server context for the request
     100 *
    100101 * @param key key for the cache entry to be fetched
     102 *
     103 * @param pool pool to allocate the response and other temporary
     104 * memory from
    101105 *
    102106 * @return the requested cache entry, or `{NULL, 0}`
    103107 */
    104 typedef gnutls_datum_t (*cache_fetch_func)(mgs_handle_t *ctxt,
    105                                            gnutls_datum_t key);
     108typedef gnutls_datum_t (*cache_fetch_func)(server_rec *server,
     109                                           gnutls_datum_t key,
     110                                           apr_pool_t *pool);
    106111/**
    107112 * Internal cache configuration structure
  • src/gnutls_ocsp.c

    rc34a68b ra85de63  
    11/*
    2  *  Copyright 2016 Fiona Klute
     2 *  Copyright 2016-2018 Fiona Klute
    33 *
    44 *  Licensed under the Apache License, Version 2.0 (the "License");
     
    772772    }
    773773
    774     *ocsp_response = sc->cache->fetch(ctxt,
    775                                       sc->ocsp->fingerprint);
     774    *ocsp_response = ctxt->sc->cache->fetch(ctxt->c->base_server,
     775                                            ctxt->sc->ocsp->fingerprint,
     776                                            ctxt->c->pool);
    776777    if (ocsp_response->size == 0)
    777778    {
     
    808809         * moment there's no good way to integrate that with the
    809810         * Apache Mutex directive. */
    810         *ocsp_response = sc->cache->fetch(ctxt,
    811                                           sc->ocsp->fingerprint);
     811        *ocsp_response = ctxt->sc->cache->fetch(ctxt->c->base_server,
     812                                                ctxt->sc->ocsp->fingerprint,
     813                                                ctxt->c->pool);
    812814        if (ocsp_response->size > 0)
    813815        {
     
    837839
    838840    /* retry reading from cache */
    839     *ocsp_response = sc->cache->fetch(ctxt,
    840                                       sc->ocsp->fingerprint);
     841    *ocsp_response = ctxt->sc->cache->fetch(ctxt->c->base_server,
     842                                            ctxt->sc->ocsp->fingerprint,
     843                                            ctxt->c->pool);
    841844    if (ocsp_response->size == 0)
    842845    {
Note: See TracChangeset for help on using the changeset viewer.