Skip to content

Commit d02fd57

Browse files
author
Marius Sturm
committed
cleanup reslist at child exit
1 parent 2b54ff1 commit d02fd57

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/mod_log_gelf.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static gelf_connection* log_gelf_connection_acquire(request_rec* r) {
203203
rv = apr_reslist_acquire(config->connection_pool, (void**)&con);
204204
if (rv != APR_SUCCESS || !con) {
205205
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
206-
"mod_log_gelf: Failed to acquire GELF connection from pool %s",
206+
"mod_log_gelf: Failed to acquire GELF connection from pool: %s",
207207
apr_strerror(rv, errbuf, sizeof(errbuf)));
208208
return NULL;
209209
}
@@ -237,7 +237,7 @@ static apr_status_t log_gelf_get_gelf_connection(gelf_connection *gc, gelf_confi
237237

238238
if (verbose > 0) {
239239
ap_log_perror(APLOG_MARK, APLOG_NOTICE, 0, pool,
240-
"mod_log_gelf: Connecting to server %s", config->server);
240+
"mod_log_gelf: Connecting to server: %s", config->server);
241241
}
242242

243243
rv = apr_sockaddr_info_get(&gc->sa, config->server, APR_INET, config->port, 0, pool);
@@ -337,6 +337,19 @@ static apr_status_t gelf_pool_destruct(void* resource, void* params, apr_pool_t*
337337
return APR_SUCCESS ;
338338
}
339339

340+
static apr_status_t log_gelf_child_exit(void *resource) {
341+
apr_reslist_t *connection_pool = resource;
342+
apr_pool_t *pool = NULL;
343+
apr_pool_create(&pool, NULL);
344+
345+
346+
while (apr_reslist_acquired_count(connection_pool) != 0) {
347+
ap_log_perror(APLOG_MARK, APLOG_ERR, 0, pool,
348+
"mod_log_gelf: Socket pool not empty: %i", apr_reslist_acquired_count(connection_pool));
349+
}
350+
apr_reslist_destroy(connection_pool);
351+
}
352+
340353
/* Registered hooks */
341354
static int log_gelf_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *server) {
342355
gelf_config *config = ap_get_module_config(server->module_config, &log_gelf_module);
@@ -354,8 +367,10 @@ static int log_gelf_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte
354367
config->enabled = 0;
355368
return OK;
356369
}
370+
// apr_pool_cleanup_register(p, config->connection_pool,
371+
// (void*)apr_reslist_destroy, apr_pool_cleanup_null);
357372
apr_pool_cleanup_register(p, config->connection_pool,
358-
(void*)apr_reslist_destroy, apr_pool_cleanup_null);
373+
log_gelf_child_exit, log_gelf_child_exit);
359374

360375
/* allocate memory for log items */
361376
config->parsed_fields = apr_pcalloc(config->parse_pool, strlen(config->fields) * sizeof(log_item *));

0 commit comments

Comments
 (0)