Changeset c55902b in mod_gnutls


Ignore:
Timestamp:
Jun 8, 2016, 5:24:15 PM (3 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, master, upstream
Children:
c6572ec
Parents:
c005645
Message:

Trigger cache expiration on fetch, small restructuring

In a situation with few stores cache entries might have remained
significantly longer than intended. Expiring before fetch if necessary
prevents that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    rc005645 rc55902b  
    318318 * confusing: "store" and "expire" take a server_rec, "fetch" an
    319319 * mgs_handle_t, and "delete" the void* required for a
    320  * gnutls_db_remove_func. The first three have matching ..._session
     320 * gnutls_db_remove_func. The first two have matching ..._session
    321321 * functions to fit their respective GnuTLS session cache signatures.
    322322 *
     
    412412    apr_status_t rv;
    413413
     414    /* check if it is time for cache expiration */
     415    dbm_cache_expire(ctxt->c->base_server);
     416
    414417    apr_global_mutex_lock(ctxt->sc->cache_mutex);
    415418
     
    427430    rv = apr_dbm_fetch(dbm, dbmkey, &dbmval);
    428431
    429     if (rv != APR_SUCCESS) {
    430         apr_dbm_close(dbm);
    431         apr_global_mutex_unlock(ctxt->sc->cache_mutex);
    432         return data;
    433     }
    434 
    435     if (dbmval.dptr == NULL || dbmval.dsize <= sizeof (apr_time_t)) {
    436         apr_dbm_freedatum(dbm, dbmval);
    437         apr_dbm_close(dbm);
    438         apr_global_mutex_unlock(ctxt->sc->cache_mutex);
    439         return data;
    440     }
     432    if (rv != APR_SUCCESS)
     433        goto close_db;
     434
     435    if (dbmval.dptr == NULL || dbmval.dsize <= sizeof (apr_time_t))
     436        goto cleanup;
    441437
    442438    data.size = dbmval.dsize - sizeof (apr_time_t);
    443439
    444440    data.data = gnutls_malloc(data.size);
    445     if (data.data == NULL) {
    446         apr_dbm_freedatum(dbm, dbmval);
    447         apr_dbm_close(dbm);
    448         apr_global_mutex_unlock(ctxt->sc->cache_mutex);
    449         return data;
    450     }
     441    if (data.data == NULL)
     442        goto cleanup;
    451443
    452444    ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, ctxt->c,
     
    456448    memcpy(data.data, dbmval.dptr + sizeof (apr_time_t), data.size);
    457449
     450 cleanup:
    458451    apr_dbm_freedatum(dbm, dbmval);
     452 close_db:
    459453    apr_dbm_close(dbm);
    460454    apr_global_mutex_unlock(ctxt->sc->cache_mutex);
     
    487481    apr_pool_t *spool;
    488482
    489     /* we expire dbm only on every store */
     483    /* check if it is time for cache expiration */
    490484    dbm_cache_expire(s);
    491485
     
    554548}
    555549
    556 static int dbm_cache_delete(void *baton, gnutls_datum_t key) {
     550static int dbm_cache_delete(void *baton, gnutls_datum_t key)
     551{
    557552    apr_dbm_t *dbm;
    558553    gnutls_datum_t tmpkey;
Note: See TracChangeset for help on using the changeset viewer.