Skip to content

Commit 765ad96

Browse files
authored
Merge pull request #211 from jbo-ads/es-thread-safety
Fix thread-safety issue with ElasticSearch second level dimensions
2 parents 8e8ad23 + 9ddee6b commit 765ad96

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

lib/dimension_es.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,6 @@ struct mapcache_dimension_elasticsearch {
4343
};
4444

4545

46-
// Hook cJSON memory allocation on APR pool mechanism
47-
static apr_pool_t * _pool_for_cJSON_malloc_hook;
48-
static void * _malloc_for_cJSON(size_t size) {
49-
return apr_palloc(_pool_for_cJSON_malloc_hook,size);
50-
}
51-
static void _free_for_cJSON(void *ptr) { }
52-
static void _create_json_pool(apr_pool_t * parent_pool) {
53-
cJSON_Hooks hooks = { _malloc_for_cJSON, _free_for_cJSON };
54-
apr_pool_create(&_pool_for_cJSON_malloc_hook,parent_pool);
55-
cJSON_InitHooks(&hooks);
56-
}
57-
static void _destroy_json_pool() {
58-
apr_pool_destroy(_pool_for_cJSON_malloc_hook);
59-
}
60-
61-
6246
static void _mapcache_dimension_elasticsearch_parse_xml(mapcache_context *ctx, mapcache_dimension *dim, ezxml_t node)
6347
{
6448
mapcache_dimension_elasticsearch *dimension;
@@ -113,14 +97,12 @@ static char * _mapcache_dimension_elasticsearch_bind_parameters(mapcache_context
11397
if (value) {
11498
// Sanitize dimension value for safe insertion in JSON request
11599
cJSON * json_str;
116-
_create_json_pool(ctx->pool);
117100
json_str = cJSON_CreateString(value);
118101
val = cJSON_Print(json_str);
119102
if (val) {
120103
// Discard double quotes while copying
121104
val = apr_pstrndup(ctx->pool,val+1,strlen(val)-2);
122105
}
123-
_destroy_json_pool();
124106
}
125107
res = mapcache_util_str_replace_all(ctx->pool,req,":dim",val);
126108

@@ -164,8 +146,6 @@ static apr_array_header_t * _mapcache_dimension_elasticsearch_do_query(mapcache_
164146
mapcache_buffer_append(buffer,1,"");
165147
resp = (char*)buffer->buf;
166148

167-
_create_json_pool(ctx->pool);
168-
169149
// Parse response format: this should be a list of keys or integers
170150
json_fmt = cJSON_Parse(response_format);
171151
if (!json_fmt) {
@@ -230,7 +210,6 @@ static apr_array_header_t * _mapcache_dimension_elasticsearch_do_query(mapcache_
230210
}
231211

232212
cleanup:
233-
_destroy_json_pool();
234213
return table;
235214
}
236215

0 commit comments

Comments
 (0)