aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-20 14:53:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-20 14:53:53 +0100
commit0bfac24ffc06be3a6eb1fbbea41447ba7c89e136 (patch)
tree7bb55f27c612b00f392efd84fa28f942bc950d71 /src
parent24867751668c77036e3fd4fcb04f2cae0cdb28b3 (diff)
downloadrspamd-0bfac24ffc06be3a6eb1fbbea41447ba7c89e136.tar.gz
rspamd-0bfac24ffc06be3a6eb1fbbea41447ba7c89e136.zip
[Fix] Fix sending data to graph command
Issue: #405
Diffstat (limited to 'src')
-rw-r--r--src/controller.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/controller.c b/src/controller.c
index 5662409d6..2659bd275 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1041,7 +1041,7 @@ rspamd_controller_graph_point (gulong t, gulong step,
for (j = 0; j < step; j++) {
yval = acc[i + j * rrd_result->ds_count];
- if (isnan(yval)) {
+ if (isnan (yval)) {
nan_cnt++;
}
else {
@@ -1081,7 +1081,7 @@ rspamd_controller_handle_graph (
struct rspamd_controller_worker_ctx *ctx;
rspamd_ftok_t srch, *value;
struct rspamd_rrd_query_result *rrd_result;
- gulong i, j, k, start_row, cnt, t, ts, step;
+ gulong i, k, start_row, cnt, t, ts, step;
gdouble *acc;
ucl_object_t *res, *elt[4];
enum {
@@ -1170,24 +1170,25 @@ rspamd_controller_handle_graph (
/* Create window */
step = (rrd_result->rra_rows / desired_points + 0.5);
+ g_assert (step >= 1);
acc = g_malloc0 (sizeof (double) * rrd_result->ds_count * step);
for (i = start_row, cnt = 0; cnt < rrd_result->rra_rows;
cnt ++) {
- for (j = 0; j < rrd_result->ds_count; j++) {
- if (k < step) {
- /* Just update window */
- acc[k * rrd_result->ds_count + j] =
- rrd_result->data[i * rrd_result->ds_count + j];
- k ++;
- }
- else {
- t = ts * rrd_result->pdp_per_cdp;
- /* Need a fresh point */
- rspamd_controller_graph_point (t, step, rrd_result, acc, elt);
- k = 0;
- }
+ memcpy (&acc[k * rrd_result->ds_count],
+ &rrd_result->data[i * rrd_result->ds_count],
+ sizeof (gdouble) * rrd_result->ds_count);
+
+ if (k < step - 1) {
+ k ++;
+ }
+ else {
+ t = ts * rrd_result->pdp_per_cdp;
+
+ /* Need a fresh point */
+ rspamd_controller_graph_point (t, step, rrd_result, acc, elt);
+ k = 0;
}
if (i == rrd_result->rra_rows - 1) {