File ganglia-0020-Fix-segfault-with-TCP-listener-thread-on-exit.patch of Package ganglia
From: Junichi TANAKA <junsan45@gmail.com>
Date: Tue, 25 Apr 2017 23:16:36 +0900
Git-commit: d63782c18ddeae5b71c976e5b8ef58a0d488beaa
References: bsc#1087487
Subject: [PATCH] Fix segfault with TCP listener thread on exit
Acked-by: John Jolly <jjolly@suse.de>
---
gmond/gmond.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/gmond/gmond.c b/gmond/gmond.c
index a188dfd9..d01555db 100644
--- a/gmond/gmond.c
+++ b/gmond/gmond.c
@@ -3315,6 +3315,7 @@ main ( int argc, char *argv[] )
{
apr_time_t now, next_collection, last_cleanup;
apr_pool_t *cleanup_context;
+ apr_thread_t *tcp_listener_thread = NULL;
gmond_argv = argv;
@@ -3436,8 +3437,7 @@ main ( int argc, char *argv[] )
/* Create TCP listener thread */
if(!deaf)
{
- apr_thread_t *thread;
- if (apr_thread_create(&thread, NULL, tcp_listener, NULL, global_context) != APR_SUCCESS)
+ if (apr_thread_create(&tcp_listener_thread, NULL, tcp_listener, NULL, global_context) != APR_SUCCESS)
{
err_msg("Failed to create TCP listener thread. Exiting.\n");
exit(EXIT_FAILURE);
@@ -3498,6 +3498,16 @@ main ( int argc, char *argv[] )
}
}
+ if(tcp_listener_thread)
+ {
+ apr_status_t status = SUCCESS;
+ if((status = apr_thread_join(&status, tcp_listener_thread)) != APR_SUCCESS)
+ {
+ char buff[512];
+ debug_msg("apr_thread_join returned unexpected status %d = %s\n", status, apr_strerror(status, buff, 511));
+ }
+ }
+
apr_pool_destroy(global_context);
if(reload_required == 1)
--
2.13.6