PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mod_mem_cache: fix seg fault under load due to pool concurrency problem
- PR: 47672
- Trunk Patch: n/a, mod_mem_cache is not in trunk
- 2.2.x Patch: https://issues.apache.org/bugzilla/attachment.cgi?id=24124
- +1: poirier, minfrin, covener, jim
-
* mod_cache: Add CacheIgnoreURLSessionIdentifiers directive to ignore
defined session identifiers encoded in the URL when caching.
Trunk version of patch:
typedef struct mem_cache_object {
apr_pool_t *pool;
+ apr_thread_mutex_t *lock; /* pools aren't thread-safe; use this lock when accessing this pool */
cache_type_e type;
apr_table_t *header_out;
apr_table_t *req_hdrs; /* for Vary negotiation */
} mem_cache_conf;
static mem_cache_conf *sconf;
+static int threaded_mpm;
+
#define DEFAULT_MAX_CACHE_SIZE 100*1024
#define DEFAULT_MIN_CACHE_OBJECT_SIZE 1
#define DEFAULT_MAX_CACHE_OBJECT_SIZE 10000
close(mobj->fd);
#endif
}
+ apr_pool_destroy(mobj->pool);
}
-
- apr_pool_destroy(mobj->pool);
}
static apr_status_t decrement_refcount(void *arg)
{
mobj = apr_pcalloc(pool, sizeof(*mobj));
mobj->pool = pool;
+ if (threaded_mpm) {
+ apr_thread_mutex_create(&mobj->lock, APR_THREAD_MUTEX_DEFAULT, pool);
+ }
+
/* Finish initing the cache object */
apr_atomic_set32(&obj->refcount, 1);
mobj->total_refs = 1;
* - The original response headers (for returning with a cached response)
* - The body of the message
*/
+ if (mobj->lock) {
+ apr_thread_mutex_lock(mobj->lock);
+ }
mobj->req_hdrs = deep_table_copy(mobj->pool, r->headers_in);
+ if (mobj->lock) {
+ apr_thread_mutex_unlock(mobj->lock);
+ }
/* Precompute how much storage we need to hold the headers */
headers_out = apr_table_overlay(r->pool, r->headers_out,
r->content_encoding);
}
+ if (mobj->lock) {
+ apr_thread_mutex_lock(mobj->lock);
+ }
mobj->header_out = deep_table_copy(mobj->pool, headers_out);
+ if (mobj->lock) {
+ apr_thread_mutex_unlock(mobj->lock);
+ }
/* Init the info struct */
obj->info.status = info->status;
static int mem_cache_post_config(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- int threaded_mpm;
-
/* Sanity check the cache configuration */
if (sconf->min_cache_object_size >= sconf->max_cache_object_size) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,