File ganglia-0001-avoid-segfault-when-fd-leaked-and-reached-fd-number-.patch of Package ganglia

From: Hiroshi Miura <miurahr@linux.com>
Date: Sun, 6 Apr 2014 10:33:08 +0900
Git-commit: 3224076c55fdc9f68fcd29bed83f401e9bbc5b0b
References: bsc#1087487
Subject: [PATCH] avoid segfault when fd leaked and reached fd number limit.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Acked-by: John Jolly <jjolly@suse.de>
---
 gmond/gmond.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gmond/gmond.c b/gmond/gmond.c
index fe51fab0..4b2fb6ef 100644
--- a/gmond/gmond.c
+++ b/gmond/gmond.c
@@ -2011,13 +2011,20 @@ process_tcp_accept_channel(const apr_pollfd_t *desc, apr_time_t now)
   channel        = desc->client_data;
 
   /* Create a context for the client connection */
-  apr_pool_create(&client_context, global_context);
+  status = apr_pool_create(&client_context, global_context);
+  if(status != APR_SUCCESS)
+    {
+      return;
+    }
 
   /* Accept the connection */
   status = apr_socket_accept(&client, server, client_context);
   if(status != APR_SUCCESS)
     {
-      goto close_accept_socket;
+      debug_msg("failed to accept");
+      /* Failed to accept, socket was not created
+       * Clear a prepared client context */
+      goto clear_client_context;
     }
 
   /* Set the timeout for writing to the client */
@@ -2125,6 +2132,7 @@ process_tcp_accept_channel(const apr_pollfd_t *desc, apr_time_t now)
 close_accept_socket:
   apr_socket_shutdown(client, APR_SHUTDOWN_READ);
   apr_socket_close(client);
+clear_client_context:
   apr_pool_destroy(client_context);
 }
 
-- 
2.13.6

openSUSE Build Service is sponsored by