[rrd-developers] [PATCH 5/5] src/rrd_graph.c: Use `rrdc_fetch' if daemon is available.

Florian Forster rrdtool at nospam.verplant.org
Sat May 23 13:04:28 CEST 2009


From: Florian Forster <octo at leeloo.lan.home.verplant.org>


Signed-off-by: Florian Forster <octo at leeloo.lan.home.verplant.org>
---
 src/rrd_graph.c |   65 +++++++++++++++++++++++-------------------------------
 1 files changed, 28 insertions(+), 37 deletions(-)

diff --git a/src/rrd_graph.c b/src/rrd_graph.c
index a0de36e..601a509 100644
--- a/src/rrd_graph.c
+++ b/src/rrd_graph.c
@@ -841,46 +841,37 @@ int data_fetch(
         if (!skip) {
             unsigned long ft_step = im->gdes[i].step;   /* ft_step will record what we got from fetch */
 
-            /* Flush the file if
-             * - a connection to the daemon has been established
-             * - this is the first occurrence of that RRD file
-             */
+	    /* If connected, use the daemon to fetch the data. */
             if (rrdc_is_connected(im->daemon_addr))
             {
-                int status;
-
-                status = 0;
-                for (ii = 0; ii < i; ii++)
-                {
-                    if (strcmp (im->gdes[i].rrd, im->gdes[ii].rrd) == 0)
-                    {
-                        status = 1;
-                        break;
-                    }
-                }
-
-                if (status == 0)
-                {
-                    status = rrdc_flush (im->gdes[i].rrd);
-                    if (status != 0)
-                    {
-                        rrd_set_error ("rrdc_flush (%s) failed with status %i.",
-                                im->gdes[i].rrd, status);
-                        return (-1);
-                    }
-                }
-            } /* if (rrdc_is_connected()) */
-
-            if ((rrd_fetch_fn(im->gdes[i].rrd,
-                              im->gdes[i].cf,
-                              &im->gdes[i].start,
-                              &im->gdes[i].end,
-                              &ft_step,
-                              &im->gdes[i].ds_cnt,
-                              &im->gdes[i].ds_namv,
-                              &im->gdes[i].data)) == -1) {
-                return -1;
+		    int status;
+
+		    status = rrdc_fetch (im->gdes[i].rrd,
+				    im->gdes[i].cf,
+				    &im->gdes[i].start,
+				    &im->gdes[i].end,
+				    &ft_step,
+				    &im->gdes[i].ds_cnt,
+				    &im->gdes[i].ds_namv,
+				    &im->gdes[i].data);
+		    if (status != 0)
+			    return (status);
             }
+	    else
+	    {
+		    int status;
+
+		    status = rrd_fetch_fn (im->gdes[i].rrd,
+				    im->gdes[i].cf,
+				    &im->gdes[i].start,
+				    &im->gdes[i].end,
+				    &ft_step,
+				    &im->gdes[i].ds_cnt,
+				    &im->gdes[i].ds_namv,
+				    &im->gdes[i].data);
+		    if (status != 0)
+			    return (status);
+	    }
             im->gdes[i].data_first = 1;
 
             if (ft_step < im->gdes[i].step) {
-- 
1.6.2.4



More information about the rrd-developers mailing list