- Timestamp:
- Apr 28, 2018, 5:52:56 PM (3 years ago)
- Branches:
- asyncio, debian/master, master, proxy-ticket
- Children:
- a314ec9
- Parents:
- 2f949bc
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gnutls_cache.c
r2f949bc rb94aee2 313 313 { 314 314 apr_status_t rv = APR_SUCCESS; 315 /* if GnuTLSCache was never explicitly set: */ 316 if (sc->cache_type == mgs_cache_unset || sc->cache_type == mgs_cache_none) 317 { 318 sc->cache_type = mgs_cache_none; 315 /* GnuTLSCache was never explicitly set or is disabled: */ 316 if (sc->cache_enable == GNUTLS_ENABLED_UNSET 317 || sc->cache_enable == GNUTLS_ENABLED_FALSE) 318 { 319 sc->cache_enable = GNUTLS_ENABLED_FALSE; 319 320 /* Cache disabled, done. */ 320 321 return APR_SUCCESS; … … 324 325 sc->cache_timeout = apr_time_from_sec(MGS_DEFAULT_CACHE_TIMEOUT); 325 326 326 /* initialize mutex only once*/327 /* initialize cache structure and mutex if needed */ 327 328 if (sc->cache == NULL) 328 329 { 329 sc->cache = apr_p alloc(pconf, sizeof(struct mgs_cache));330 sc->cache = apr_pcalloc(pconf, sizeof(struct mgs_cache)); 330 331 rv = ap_global_mutex_create(&sc->cache->mutex, NULL, 331 332 MGS_CACHE_MUTEX_NAME, … … 335 336 } 336 337 337 char *pname = NULL;338 339 if (sc->cache_type == mgs_cache_dbm || sc->cache_type == mgs_cache_gdbm)340 pname = "dbm";341 else if (sc->cache_type == mgs_cache_memcache)342 pname = "memcache";343 else if (sc->cache_type == mgs_cache_shmcb)344 pname = "shmcb";345 346 338 /* Find the right socache provider */ 347 339 sc->cache->prov = ap_lookup_provider(AP_SOCACHE_PROVIDER_GROUP, 348 pname,340 sc->cache_type, 349 341 AP_SOCACHE_PROVIDER_VERSION); 350 342 if (sc->cache->prov) … … 358 350 ap_log_error(APLOG_MARK, APLOG_EMERG, APR_EGENERAL, s, 359 351 "Creating cache '%s:%s' failed: %s", 360 pname, sc->cache_config, err);352 sc->cache_type, sc->cache_config, err); 361 353 return HTTP_INSUFFICIENT_STORAGE; 362 354 } 363 355 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, 364 "%s: Socache '%s' created.", __func__, pname);356 "%s: Socache '%s' created.", __func__, sc->cache_type); 365 357 366 358 // TODO: provide hints … … 371 363 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, 372 364 "Initializing cache '%s:%s' failed!", 373 pname, sc->cache_config);365 sc->cache_type, sc->cache_config); 374 366 return HTTP_INSUFFICIENT_STORAGE; 375 367 } 376 368 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, 377 369 "%s: socache '%s:%s' created.", __func__, 378 pname, sc->cache_config);370 sc->cache_type, sc->cache_config); 379 371 } 380 372 else … … 383 375 "Could not find socache provider '%s', please make sure " 384 376 "that the provider name is valid and the " 385 "appropriate mod_socache submodule is loaded.", pname); 377 "appropriate mod_socache submodule is loaded.", 378 sc->cache_type); 386 379 return HTTP_NOT_FOUND; 387 380 } … … 409 402 int mgs_cache_session_init(mgs_handle_t * ctxt) 410 403 { 411 if (ctxt->sc->cache_ type != mgs_cache_none)404 if (ctxt->sc->cache_enable) 412 405 { 413 406 gnutls_db_set_retrieve_function(ctxt->session, -
src/gnutls_config.c
r2f949bc rb94aee2 594 594 if (strcasecmp("none", type) == 0) 595 595 { 596 sc->cache_type = mgs_cache_none; 596 sc->cache_enable = GNUTLS_ENABLED_FALSE; 597 sc->cache_type = NULL; 597 598 sc->cache_config = NULL; 598 599 return NULL; 599 600 } 601 602 sc->cache_enable = GNUTLS_ENABLED_TRUE; 600 603 601 604 /* Try to split socache "type:config" style configuration */ … … 603 606 if (sep) 604 607 { 605 type = apr_pstrmemdup(parms->temp_pool, type, sep - type);608 sc->cache_type = apr_pstrmemdup(parms->pool, type, sep - type); 606 609 if (arg != NULL) 607 610 { … … 612 615 arg = ++sep; 613 616 } 614 615 if (strcasecmp("dbm", type) == 0) { 616 sc->cache_type = mgs_cache_dbm; 617 } else if (strcasecmp("gdbm", type) == 0) { 618 sc->cache_type = mgs_cache_gdbm; 619 } 620 else if (strcasecmp("memcache", type) == 0) { 621 sc->cache_type = mgs_cache_memcache; 622 } 623 else if (strcasecmp("shmcb", type) == 0) { 624 sc->cache_type = mgs_cache_shmcb; 625 } 626 else { 627 return "Invalid Type for GnuTLSCache!"; 628 } 617 else 618 sc->cache_type = apr_pstrdup(parms->pool, type); 629 619 630 620 if (arg == NULL) 631 return "Invalid argument 2 for GnuTLSCache!"; 632 633 if (sc->cache_type == mgs_cache_dbm 634 || sc->cache_type == mgs_cache_gdbm) { 635 sc->cache_config = ap_server_root_relative(parms->pool, arg); 636 } else { 621 sc->cache_config = ""; 622 else 637 623 sc->cache_config = apr_pstrdup(parms->pool, arg); 638 }639 624 640 625 return NULL; … … 880 865 sc->priorities_str = NULL; 881 866 sc->cache_timeout = MGS_TIMEOUT_UNSET; 882 sc->cache_type = mgs_cache_unset; 867 sc->cache_type = NULL; 868 sc->cache_enable = GNUTLS_ENABLED_UNSET; 883 869 sc->cache_config = NULL; 884 870 sc->cache = NULL; -
src/gnutls_hooks.c
r2f949bc rb94aee2 629 629 sc = (mgs_srvconf_rec *) ap_get_module_config(s->module_config, &gnutls_module); 630 630 sc->cache_type = sc_base->cache_type; 631 sc->cache_enable = sc_base->cache_enable; 631 632 sc->cache_config = sc_base->cache_config; 632 633 sc->cache_timeout = sc_base->cache_timeout; … … 774 775 } 775 776 776 if (sc->cache_ type != mgs_cache_none) {777 if (sc->cache_enable) { 777 778 rv = mgs_cache_child_init(p, s, sc); 778 779 if (rv != APR_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.