| 444 | } |
| 445 | |
| 446 | static int open_entity(cache_handle_t *h, request_rec *r, const char *key) |
| 447 | { |
| 448 | cache_socache_dir_conf *dconf = |
| 449 | ap_get_module_config(r->per_dir_config, &cache_socache_module); |
| 450 | cache_socache_conf *conf = ap_get_module_config(r->server->module_config, |
| 451 | &cache_socache_module); |
| 452 | apr_uint32_t format; |
| 453 | apr_size_t slider; |
| 454 | unsigned int buffer_len; |
| 455 | const char *nkey; |
| 456 | apr_status_t rc; |
| 457 | cache_object_t *obj; |
| 458 | cache_info *info; |
| 459 | cache_socache_object_t *sobj; |
| 460 | apr_size_t len; |
| 461 | |
| 462 | nkey = NULL; |
| 463 | h->cache_obj = NULL; |
| 464 | |
| 465 | if (!conf->provider || !conf->provider->socache_instance) { |
| 466 | return DECLINED; |
| 467 | } |
| 468 | |
| 469 | /* Create and init the cache object */ |
| 470 | obj = apr_pcalloc(r->pool, sizeof(cache_object_t)); |
| 471 | sobj = apr_pcalloc(r->pool, sizeof(cache_socache_object_t)); |
| 472 | |
| 473 | info = &(obj->info); |
| 474 | |
| 475 | /* Create a temporary pool for the buffer, and destroy it if something |
| 476 | * goes wrong so we don't have large buffers of unused memory hanging |
| 477 | * about for the lifetime of the response. |
| 478 | */ |
| 479 | apr_pool_create(&sobj->pool, r->pool); |
| 480 | apr_pool_tag(sobj->pool, "mod_cache_socache (open_entity)"); |
| 481 | |
| 482 | sobj->buffer = apr_palloc(sobj->pool, dconf->max); |
| 483 | sobj->buffer_len = dconf->max; |
| 484 | |
| 485 | /* attempt to retrieve the cached entry */ |
| 486 | if (socache_mutex) { |
| 487 | apr_status_t status = apr_global_mutex_lock(socache_mutex); |
| 488 | if (status != APR_SUCCESS) { |
| 489 | ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02350) |
| 490 | "could not acquire lock, ignoring: %s", obj->key); |
| 491 | apr_pool_destroy(sobj->pool); |
| 492 | sobj->pool = NULL; |
| 493 | return DECLINED; |
| 494 | } |
| 495 | } |
| 496 | buffer_len = sobj->buffer_len; |
| 497 | rc = conf->provider->socache_provider->retrieve( |
| 498 | conf->provider->socache_instance, r->server, (unsigned char *) key, |
| 499 | strlen(key), sobj->buffer, &buffer_len, r->pool); |
| 500 | if (socache_mutex) { |
| 501 | apr_status_t status = apr_global_mutex_unlock(socache_mutex); |
| 502 | if (status != APR_SUCCESS) { |
| 503 | ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02351) |
nothing calls this directly
no test coverage detected