Changeset ae08186 in mod_gnutls


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

DBM cache: Separate session caching and generic store operation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    rf785704 rae08186  
    427427}
    428428
    429 static int dbm_cache_store(void *baton, gnutls_datum_t key,
    430         gnutls_datum_t data) {
     429static int dbm_cache_store(void *baton, apr_datum_t key,
     430                           gnutls_datum_t data, apr_time_t expiry)
     431{
    431432    apr_dbm_t *dbm;
    432     apr_datum_t dbmkey;
    433433    apr_datum_t dbmval;
    434434    mgs_handle_t *ctxt = baton;
    435435    apr_status_t rv;
    436     apr_time_t expiry;
    437436    apr_pool_t *spool;
    438 
    439     if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
    440         return -1;
    441437
    442438    /* we expire dbm only on every store
     
    450446    dbmval.dptr = (char *) apr_palloc(spool, dbmval.dsize);
    451447
    452     expiry = apr_time_now() + ctxt->sc->cache_timeout;
    453 
     448    /* prepend expiration time */
    454449    memcpy((char *) dbmval.dptr, &expiry, sizeof (apr_time_t));
    455450    memcpy((char *) dbmval.dptr + sizeof (apr_time_t),
     
    468463    }
    469464
    470     rv = apr_dbm_store(dbm, dbmkey, dbmval);
     465    rv = apr_dbm_store(dbm, key, dbmval);
    471466
    472467    if (rv != APR_SUCCESS) {
     
    485480
    486481    return 0;
     482}
     483
     484static int dbm_cache_store_session(void *baton, gnutls_datum_t key,
     485                                   gnutls_datum_t data)
     486{
     487    mgs_handle_t *ctxt = baton;
     488    apr_datum_t dbmkey;
     489
     490    if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
     491        return -1;
     492
     493    apr_time_t expiry = apr_time_now() + ctxt->sc->cache_timeout;
     494
     495    return dbm_cache_store(baton, dbmkey, data, expiry);
    487496}
    488497
     
    614623                dbm_cache_delete);
    615624        gnutls_db_set_store_function(ctxt->session,
    616                 dbm_cache_store);
     625                dbm_cache_store_session);
    617626        gnutls_db_set_ptr(ctxt->session, ctxt);
    618627    }
Note: See TracChangeset for help on using the changeset viewer.