Changeset 15245bf in mod_gnutls


Ignore:
Timestamp:
Jun 5, 2016, 3:42:31 PM (3 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, master, upstream
Children:
6814e48
Parents:
1d1361f
git-author:
Thomas Klute <thomas2.klute@…> (06/04/16 21:41:33)
git-committer:
Thomas Klute <thomas2.klute@…> (06/05/16 15:42:31)
Message:

Split dbm_cache_fetch() in generic and GnuTLS session specific parts

Like with dbm_cache_store(), a new wrapper function takes care of
session key calculation. This change will make it possible to use the
generic dbm_cache_fetch() for OCSP response caching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    r1d1361f r15245bf  
    375375}
    376376
    377 static gnutls_datum_t dbm_cache_fetch(void *baton, gnutls_datum_t key) {
     377static gnutls_datum_t dbm_cache_fetch(mgs_handle_t *ctxt, apr_datum_t key)
     378{
    378379    gnutls_datum_t data = {NULL, 0};
    379380    apr_dbm_t *dbm;
    380     apr_datum_t dbmkey;
    381381    apr_datum_t dbmval;
    382     mgs_handle_t *ctxt = baton;
    383382    apr_status_t rv;
    384 
    385     if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
    386         return data;
    387383
    388384    rv = apr_dbm_open_ex(&dbm, db_type(ctxt->sc),
     
    390386            SSL_DBM_FILE_MODE, ctxt->c->pool);
    391387    if (rv != APR_SUCCESS) {
    392         ap_log_error(APLOG_MARK, APLOG_NOTICE, rv,
    393                 ctxt->c->base_server,
    394                 "[gnutls_cache] error opening cache '%s'",
    395                 ctxt->sc->cache_config);
    396         return data;
    397     }
    398 
    399     rv = apr_dbm_fetch(dbm, dbmkey, &dbmval);
     388        ap_log_cerror(APLOG_MARK, APLOG_NOTICE, rv, ctxt->c,
     389                      "error opening cache '%s'",
     390                      ctxt->sc->cache_config);
     391        return data;
     392    }
     393
     394    rv = apr_dbm_fetch(dbm, key, &dbmval);
    400395
    401396    if (rv != APR_SUCCESS) {
     
    419414    }
    420415
     416    ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, ctxt->c,
     417                  "fetched %ld bytes from cache",
     418                  dbmval.dsize);
     419
    421420    memcpy(data.data, dbmval.dptr + sizeof (apr_time_t), data.size);
    422421
     
    425424
    426425    return data;
     426}
     427
     428static gnutls_datum_t dbm_cache_fetch_session(void *baton,
     429                                              gnutls_datum_t key)
     430{
     431    gnutls_datum_t data = {NULL, 0};
     432    apr_datum_t dbmkey;
     433    mgs_handle_t *ctxt = baton;
     434
     435    if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
     436        return data;
     437
     438    return dbm_cache_fetch(ctxt, dbmkey);
    427439}
    428440
     
    623635            || ctxt->sc->cache_type == mgs_cache_gdbm) {
    624636        gnutls_db_set_retrieve_function(ctxt->session,
    625                 dbm_cache_fetch);
     637                dbm_cache_fetch_session);
    626638        gnutls_db_set_remove_function(ctxt->session,
    627639                dbm_cache_delete);
Note: See TracChangeset for help on using the changeset viewer.