From 2159a4b6fc6c9ded8e4974b09c5cc78e69c6a7f3 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 28 Nov 2013 13:53:39 +0000 Subject: fix div by zero --- src/transport/gnunet-service-transport_neighbours.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 49470d366..268513795 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -2394,19 +2394,20 @@ send_utilization_data (void *cls, delta = GNUNET_TIME_absolute_get_difference(n->last_util_transmission, GNUNET_TIME_absolute_get()); bps_pl_in = 0; - if (0 != n->util_payload_bytes_recv) + + if ((0 != n->util_payload_bytes_recv) && (0 != delta.rel_value_us)) bps_pl_in = (1000LL * 1000LL * n->util_payload_bytes_recv) / (delta.rel_value_us); bps_pl_out = 0; - if (0 != n->util_payload_bytes_sent) + if ((0 != n->util_payload_bytes_sent) && (0 != delta.rel_value_us)) bps_pl_out = (1000LL * 1000LL * n->util_payload_bytes_sent) / delta.rel_value_us; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' payload: received %u Bytes/s, sent %u Bytes/s \n", GNUNET_i2s (key), bps_pl_in, bps_pl_out); bps_in = 0; - if (0 != n->util_total_bytes_recv) + if ((0 != n->util_total_bytes_recv) && (0 != delta.rel_value_us)) bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us); bps_out = 0; - if (0 != n->util_total_bytes_sent) + if ((0 != n->util_total_bytes_sent) && (0 != delta.rel_value_us)) bps_out = (1000LL * 1000LL * n->util_total_bytes_sent) / delta.rel_value_us; -- cgit v1.2.3