Skip to content

Commit

Permalink
Fix connection pooling on virtualhosts, and segfaults when terminatin…
Browse files Browse the repository at this point in the history
…g child workers
  • Loading branch information
tbonfort committed Sep 23, 2015
1 parent 0829425 commit 5901ab3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions apache/mod_mapcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,16 @@ static int write_http_response(mapcache_context_apache_request *ctx, mapcache_ht
static void mod_mapcache_child_init(apr_pool_t *pool, server_rec *s)
{
int rv;
mapcache_server_cfg* cfg = ap_get_module_config(s->module_config, &mapcache_module);
#ifdef APR_HAS_THREADS
apr_thread_mutex_create(&thread_mutex,APR_THREAD_MUTEX_DEFAULT,pool);
#endif
rv = mapcache_connection_pool_create(&(cfg->cp),pool);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "creating a mapcache connection pool for server");
if(rv!=APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "failed to create mapcache connection pool");
for( ; s ; s=s->next) {
mapcache_server_cfg* cfg = ap_get_module_config(s->module_config, &mapcache_module);
rv = mapcache_connection_pool_create(&(cfg->cp),pool);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "creating a mapcache connection pool for child process");
if(rv!=APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "failed to create mapcache connection pool");
}
}
}

Expand Down Expand Up @@ -449,7 +451,6 @@ static int mod_mapcache_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "configuration not found in server context");
return 1;
}


#ifdef USE_VERSION_STRING
ap_add_version_component(p, MAPCACHE_USERAGENT);
Expand Down Expand Up @@ -566,7 +567,7 @@ static void *mod_mapcache_merge_server_conf(apr_pool_t *p, void *base_, void *vh
} else if (base->aliases) {
cfg->aliases = apr_hash_copy(p,base->aliases);
}
return vhost;
return cfg;
}

static const char* mapcache_add_alias(cmd_parms *cmd, void *cfg, const char *alias, const char* configfile)
Expand Down
4 changes: 2 additions & 2 deletions lib/cache_memcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void mapcache_memcache_connection_constructor(mapcache_context *ctx, void **conn
struct mapcache_memcache_pooled_connection *pc;
int i;
pc = calloc(1,sizeof(struct mapcache_memcache_pooled_connection));
apr_pool_create(&pc->pool,process_pool);
apr_pool_create(&pc->pool,NULL);
if(APR_SUCCESS != apr_memcache_create(pc->pool, cache->nservers, 0, &(pc->memcache))) {
ctx->set_error(ctx,500,"cache %s: failed to create memcache backend", cache->cache.name);
return;
Expand Down Expand Up @@ -186,7 +186,7 @@ static int _mapcache_cache_memcache_get(mapcache_context *ctx, mapcache_cache *p
&(((char*)encoded_data->buf)[encoded_data->size-sizeof(apr_time_t)]),
sizeof(apr_time_t));

((char*)encoded_data->buf)[encoded_data->size+sizeof(apr_time_t)]='\0';
((char*)encoded_data->buf)[encoded_data->size-sizeof(apr_time_t)]='\0';
encoded_data->avail = encoded_data->size;
encoded_data->size -= sizeof(apr_time_t);
if(((char*)encoded_data->buf)[0] == '#' && encoded_data->size > 1) {
Expand Down

0 comments on commit 5901ab3

Please sign in to comment.