Code

frontend/query: Simplified code a little.
authorSebastian Harl <sh@tokkee.org>
Tue, 26 Jan 2016 22:32:33 +0000 (23:32 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 26 Jan 2016 22:32:33 +0000 (23:32 +0100)
src/frontend/query.c

index 5e44329..2e28324 100644 (file)
@@ -248,7 +248,11 @@ exec_timeseries(sdb_ast_timeseries_t *ts, sdb_strbuf_t *buf, sdb_strbuf_t *errbu
        }
        if (status >= 0) {
                series = sdb_plugin_fetch_timeseries(st.type, st.id, &opts);
        }
        if (status >= 0) {
                series = sdb_plugin_fetch_timeseries(st.type, st.id, &opts);
-               if (! series) {
+               if (series) {
+                       sdb_timeseries_tojson(series, buf);
+                       sdb_timeseries_destroy(series);
+               }
+               else {
                        sdb_log(SDB_LOG_ERR, "frontend: Failed to fetch time-series '%s/%s' "
                                        "- %s fetcher callback returned no data for '%s'",
                                        ts->hostname, ts->metric, st.type, st.id);
                        sdb_log(SDB_LOG_ERR, "frontend: Failed to fetch time-series '%s/%s' "
                                        "- %s fetcher callback returned no data for '%s'",
                                        ts->hostname, ts->metric, st.type, st.id);
@@ -256,11 +260,6 @@ exec_timeseries(sdb_ast_timeseries_t *ts, sdb_strbuf_t *buf, sdb_strbuf_t *errbu
                }
        }
 
                }
        }
 
-       if (status >= 0) {
-               sdb_timeseries_tojson(series, buf);
-               sdb_timeseries_destroy(series);
-       }
-
        free(fetch.hostname);
        free(fetch.name);
        if (st.type)
        free(fetch.hostname);
        free(fetch.name);
        if (st.type)