X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Foping.c;h=b4999c5c11f7e9aff2a585d02c2a6a25390849c2;hb=8291dce0cd5f40fc849c0c492a42605ccd9246f8;hp=e439dbfc7b3863ffb504664f01500842fe2761b2;hpb=c19bb6cbb0e9e4946b1bffdd1fec7e6250bc43e5;p=liboping.git diff --git a/src/oping.c b/src/oping.c index e439dbf..b4999c5 100644 --- a/src/oping.c +++ b/src/oping.c @@ -293,6 +293,11 @@ static void clean_history (ping_context_t *ctx) /* {{{ */ memcpy (ctx->history_by_value, ctx->history_by_time, sizeof (ctx->history_by_time)); + /* Remove impossible values */ + for (i = 0; i < ctx->history_size; i++) + if (ctx->history_by_value[i]<0) + ctx->history_by_value[i]=NAN; + /* Sort all RTTs. */ qsort (ctx->history_by_value, ctx->history_size, sizeof (ctx->history_by_value[0]), compare_double); @@ -1046,6 +1051,10 @@ static int update_graph_prettyping (ping_context_t *ctx, /* {{{ */ index = (history_offset + x) % ctx->history_size; latency = ctx->history_by_time[index]; + if (latency < 0) { + continue; + } + if (latency >= 0.0) { double ratio;