aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-11-28 13:53:39 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-11-28 13:53:39 +0000
commit2159a4b6fc6c9ded8e4974b09c5cc78e69c6a7f3 (patch)
tree2fedd19aa7cb0d9a56ef2fb16ebc1a53cd35f450 /src
parentce50b8a84417f171483a2897d47bb20758d664ef (diff)
downloadgnunet-2159a4b6fc6c9ded8e4974b09c5cc78e69c6a7f3.tar.gz
gnunet-2159a4b6fc6c9ded8e4974b09c5cc78e69c6a7f3.zip
fix div by zero
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c9
1 files changed, 5 insertions, 4 deletions
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,
2394 delta = GNUNET_TIME_absolute_get_difference(n->last_util_transmission, GNUNET_TIME_absolute_get()); 2394 delta = GNUNET_TIME_absolute_get_difference(n->last_util_transmission, GNUNET_TIME_absolute_get());
2395 2395
2396 bps_pl_in = 0; 2396 bps_pl_in = 0;
2397 if (0 != n->util_payload_bytes_recv) 2397
2398 if ((0 != n->util_payload_bytes_recv) && (0 != delta.rel_value_us))
2398 bps_pl_in = (1000LL * 1000LL * n->util_payload_bytes_recv) / (delta.rel_value_us); 2399 bps_pl_in = (1000LL * 1000LL * n->util_payload_bytes_recv) / (delta.rel_value_us);
2399 bps_pl_out = 0; 2400 bps_pl_out = 0;
2400 if (0 != n->util_payload_bytes_sent) 2401 if ((0 != n->util_payload_bytes_sent) && (0 != delta.rel_value_us))
2401 bps_pl_out = (1000LL * 1000LL * n->util_payload_bytes_sent) / delta.rel_value_us; 2402 bps_pl_out = (1000LL * 1000LL * n->util_payload_bytes_sent) / delta.rel_value_us;
2402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' payload: received %u Bytes/s, sent %u Bytes/s \n", 2403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' payload: received %u Bytes/s, sent %u Bytes/s \n",
2403 GNUNET_i2s (key), bps_pl_in, bps_pl_out); 2404 GNUNET_i2s (key), bps_pl_in, bps_pl_out);
2404 2405
2405 bps_in = 0; 2406 bps_in = 0;
2406 if (0 != n->util_total_bytes_recv) 2407 if ((0 != n->util_total_bytes_recv) && (0 != delta.rel_value_us))
2407 bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us); 2408 bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us);
2408 bps_out = 0; 2409 bps_out = 0;
2409 if (0 != n->util_total_bytes_sent) 2410 if ((0 != n->util_total_bytes_sent) && (0 != delta.rel_value_us))
2410 bps_out = (1000LL * 1000LL * n->util_total_bytes_sent) / delta.rel_value_us; 2411 bps_out = (1000LL * 1000LL * n->util_total_bytes_sent) / delta.rel_value_us;
2411 2412
2412 2413