[rrd-developers] [PATCH] error handling in rrd_client.c

Tobias Oetiker tobi at oetiker.ch
Fri Apr 30 17:50:29 CEST 2010


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
> rrd-developers at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900



More information about the rrd-developers mailing list