Changeset 1de1026 in mod_gnutls for src/gnutls_ocsp.c


Ignore:
Timestamp:
Dec 5, 2017, 1:18:49 PM (2 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, master, upstream
Children:
fe21671
Parents:
994a5fb
Message:

mgs_get_ocsp_response(): Separate mgs_srvconf_rec* variable for readability

Having a separate variable instead of referencing ctxt every time
simplifies and shortens a lot of lines in this function. Technically
ctxt->sc is equal to the void *ptr parameter, but it's more explicit
this way, and also allows changing the custom pointer in the future
without changing the callback function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_ocsp.c

    r994a5fb r1de1026  
    742742{
    743743    mgs_handle_t *ctxt = gnutls_session_get_ptr(session);
    744     if (!ctxt->sc->ocsp_staple || ctxt->sc->cache == NULL)
     744    mgs_srvconf_rec *sc = ctxt->sc;
     745
     746    if (!sc->ocsp_staple || sc->cache == NULL)
    745747    {
    746748        /* OCSP must be enabled and caching requires a cache. */
     
    748750    }
    749751
    750     *ocsp_response = ctxt->sc->cache->fetch(ctxt,
    751                                             ctxt->sc->ocsp->fingerprint);
     752    *ocsp_response = sc->cache->fetch(ctxt,
     753                                      sc->ocsp->fingerprint);
    752754    if (ocsp_response->size == 0)
    753755    {
     
    775777                  "No valid OCSP response in cache, trying to update.");
    776778
    777     apr_status_t rv = apr_global_mutex_trylock(ctxt->sc->ocsp_mutex);
     779    apr_status_t rv = apr_global_mutex_trylock(sc->ocsp_mutex);
    778780    if (APR_STATUS_IS_EBUSY(rv))
    779781    {
    780782        /* Another thread is currently holding the mutex, wait. */
    781         apr_global_mutex_lock(ctxt->sc->ocsp_mutex);
     783        apr_global_mutex_lock(sc->ocsp_mutex);
    782784        /* Check if this other thread updated the response we need. It
    783785         * would be better to have a vhost specific mutex, but at the
    784786         * moment there's no good way to integrate that with the
    785787         * Apache Mutex directive. */
    786         *ocsp_response = ctxt->sc->cache->fetch(ctxt,
    787                                                 ctxt->sc->ocsp->fingerprint);
     788        *ocsp_response = sc->cache->fetch(ctxt,
     789                                          sc->ocsp->fingerprint);
    788790        if (ocsp_response->size > 0)
    789791        {
    790792            /* Got a valid response now, unlock mutex and return. */
    791             apr_global_mutex_unlock(ctxt->sc->ocsp_mutex);
     793            apr_global_mutex_unlock(sc->ocsp_mutex);
    792794            return GNUTLS_E_SUCCESS;
    793795        }
     
    806808        /* cache failure to rate limit retries */
    807809        mgs_cache_ocsp_failure(ctxt->c->base_server);
    808         apr_global_mutex_unlock(ctxt->sc->ocsp_mutex);
     810        apr_global_mutex_unlock(sc->ocsp_mutex);
    809811        goto fail_cleanup;
    810812    }
    811     apr_global_mutex_unlock(ctxt->sc->ocsp_mutex);
     813    apr_global_mutex_unlock(sc->ocsp_mutex);
    812814
    813815    /* retry reading from cache */
    814     *ocsp_response = ctxt->sc->cache->fetch(ctxt,
    815                                             ctxt->sc->ocsp->fingerprint);
     816    *ocsp_response = sc->cache->fetch(ctxt,
     817                                      sc->ocsp->fingerprint);
    816818    if (ocsp_response->size == 0)
    817819    {
Note: See TracChangeset for help on using the changeset viewer.