aboutsummaryrefslogtreecommitdiff
path: root/src/util/bandwidth.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-10-27 09:21:14 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-10-27 09:21:14 +0000
commit71f77f1be3d6e2da1b88fe4a4fdd44c3c69b5325 (patch)
tree5570130fdab90ad02f4b5bfda414d13161f0f3d1 /src/util/bandwidth.c
parent1d7368a52af332af35ec6de22affef4f5f0c1da4 (diff)
downloadgnunet-71f77f1be3d6e2da1b88fe4a4fdd44c3c69b5325.tar.gz
gnunet-71f77f1be3d6e2da1b88fe4a4fdd44c3c69b5325.zip
Changed GNUNET_TIME_Absolute and GNUNET_TIME_Relative to allow safe comparisons between time values
Diffstat (limited to 'src/util/bandwidth.c')
-rw-r--r--src/util/bandwidth.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 4e34f6f06..86181ec70 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -84,10 +84,10 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO b
84#if DEBUG_BANDWIDTH 84#if DEBUG_BANDWIDTH
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Bandwidth has %llu bytes available until deadline in %llums\n", 86 "Bandwidth has %llu bytes available until deadline in %llums\n",
87 (unsigned long long) ((b * deadline.value + 500LL) / 1000LL), 87 (unsigned long long) ((b * deadline.abs_value + 500LL) / 1000LL),
88 deadline.value); 88 deadline.abs_value);
89#endif 89#endif
90 return (b * deadline.value + 500LL) / 1000LL; 90 return (b * deadline.rel_value + 500LL) / 1000LL;
91} 91}
92 92
93 93
@@ -115,11 +115,11 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
115#endif 115#endif
116 return GNUNET_TIME_UNIT_FOREVER_REL; 116 return GNUNET_TIME_UNIT_FOREVER_REL;
117 } 117 }
118 ret.value = size * 1000LL / b; 118 ret.rel_value = size * 1000LL / b;
119#if DEBUG_BANDWIDTH 119#if DEBUG_BANDWIDTH
120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
121 "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n", 121 "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
122 (unsigned long long) ret.value, 122 (unsigned long long) ret.abs_value,
123 (unsigned long long) size); 123 (unsigned long long) size);
124#endif 124#endif
125 return ret; 125 return ret;
@@ -175,7 +175,7 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
175 uint64_t max_carry; 175 uint64_t max_carry;
176 176
177 now = GNUNET_TIME_absolute_get (); 177 now = GNUNET_TIME_absolute_get ();
178 delta_time = now.value - av->last_update__.value; 178 delta_time = now.abs_value - av->last_update__.abs_value;
179 delta_avail = (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 500LL) / 1000LL; 179 delta_avail = (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 500LL) / 1000LL;
180 av->consumption_since_last_update__ -= delta_avail; 180 av->consumption_since_last_update__ -= delta_avail;
181 av->last_update__ = now; 181 av->last_update__ = now;
@@ -291,13 +291,13 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av,
291#endif 291#endif
292 return GNUNET_TIME_UNIT_ZERO; 292 return GNUNET_TIME_UNIT_ZERO;
293 } 293 }
294 ret.value = 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__; 294 ret.rel_value = 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__;
295#if DEBUG_BANDWIDTH 295#if DEBUG_BANDWIDTH
296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
297 "Tracker %p delay for %u bytes is %llu ms\n", 297 "Tracker %p delay for %u bytes is %llu ms\n",
298 av, 298 av,
299 (unsigned int) size, 299 (unsigned int) size,
300 (unsigned long long) ret.value); 300 (unsigned long long) ret.abs_value);
301#endif 301#endif
302 return ret; 302 return ret;
303} 303}