From 9ff46c8d0cd1f3b7629fb9addd21d3d9e213ac09 Mon Sep 17 00:00:00 2001 From: oetiker Date: Fri, 30 Apr 2010 15:50:16 +0000 Subject: [PATCH] rrd_client.c: explicitly close the connection on error in response_read. I've found it to get stuck otherwise. -- Thorsten von Eicken git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2075 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/program/src/rrd_client.c b/program/src/rrd_client.c index 471e046f..308965e2 100644 --- a/program/src/rrd_client.c +++ b/program/src/rrd_client.c @@ -245,14 +245,17 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */ ret->lines_num = 0; buffer_ptr = fgets (buffer, sizeof (buffer), sh); - if (buffer_ptr == NULL) + if (buffer_ptr == NULL) { + close_connection(); return (-3); + } chomp (buffer); ret->status = strtol (buffer, &ret->message, 0); if (buffer == ret->message) { response_free (ret); + close_connection(); return (-4); } /* Skip leading whitespace of the status message */ @@ -270,6 +273,7 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */ if (ret->lines == NULL) { response_free (ret); + close_connection(); return (-5); } memset (ret->lines, 0, sizeof (char *) * ret->status); @@ -281,6 +285,7 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */ if (buffer_ptr == NULL) { response_free (ret); + close_connection(); return (-6); } chomp (buffer); @@ -289,6 +294,7 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */ if (ret->lines[i] == NULL) { response_free (ret); + close_connection(); return (-7); } } -- 2.30.2