Re: [PATCH] error handling in rrd_client.c

Tobias Oetiker <[email protected]>
Newsgroups gmane.comp.db.rrdtool.devel
Message-ID <[email protected]>
Hi Thorsten,

Today Thorsten von Eicken wrote:

> The patch below explicitly closes the connection on error in
> response_read. I've found it to get stuck otherwise.
>      TvE

thanks
tobi
>
> # diff -u rrd_client.c.orig rrd_client.c
> --- rrd_client.c.orig   2010-03-29 17:03:57.000000000 +0000
> +++ rrd_client.c        2010-04-20 22:10:28.000000000 +0000
> @@ -371,14 +371,17 @@
>     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 */
> @@ -396,6 +399,7 @@
>     if (ret->lines == NULL)
>     {
>       response_free (ret);
> +    close_connection();
>       return (-5);
>     }
>     memset (ret->lines, 0, sizeof (char *) * ret->status);
> @@ -407,6 +411,7 @@
>       if (buffer_ptr == NULL)
>       {
>         response_free (ret);
> +      close_connection();
>         return (-6);
>       }
>       chomp (buffer);
> @@ -415,6 +420,7 @@
>       if (ret->lines[i] == NULL)
>       {
>         response_free (ret);
> +      close_connection();
>         return (-7);
>       }
>     }
>
> _______________________________________________
> rrd-developers mailing list
> [email protected]
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch [email protected] ++41 62 775 9902 / sb: -9900
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.