projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
proper shutdown
[oweals/gnunet.git]
/
src
/
util
/
bandwidth.c
diff --git
a/src/util/bandwidth.c
b/src/util/bandwidth.c
index 38e5027d0469d86536b427faa2870ee45a76d316..6f25abfd523bc23870c59a14a1734adf7c9e6162 100644
(file)
--- a/
src/util/bandwidth.c
+++ b/
src/util/bandwidth.c
@@
-42,7
+42,7
@@
GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second)
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Initializing bandwidth of %u
b
ps\n",
+ "Initializing bandwidth of %u
B
ps\n",
(unsigned int) bytes_per_second);
#endif
ret.value__ = htonl (bytes_per_second);
(unsigned int) bytes_per_second);
#endif
ret.value__ = htonl (bytes_per_second);
@@
-84,10
+84,10
@@
GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO b
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth has %llu bytes available until deadline in %llums\n",
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth has %llu bytes available until deadline in %llums\n",
- (unsigned long long) ((b * deadline.value + 500LL) / 1000LL),
- deadline.value);
+ (unsigned long long) ((b * deadline.
rel_
value + 500LL) / 1000LL),
+ deadline.
rel_
value);
#endif
#endif
- return (b * deadline.value + 500LL) / 1000LL;
+ return (b * deadline.
rel_
value + 500LL) / 1000LL;
}
}
@@
-115,11
+115,11
@@
GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
#endif
return GNUNET_TIME_UNIT_FOREVER_REL;
}
#endif
return GNUNET_TIME_UNIT_FOREVER_REL;
}
- ret.value = size * 1000LL / b;
+ ret.
rel_
value = size * 1000LL / b;
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
- (unsigned long long) ret.value,
+ (unsigned long long) ret.
rel_
value,
(unsigned long long) size);
#endif
return ret;
(unsigned long long) size);
#endif
return ret;
@@
-151,7
+151,7
@@
GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av,
av->max_carry_s__ = max_carry_s;
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
av->max_carry_s__ = max_carry_s;
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tracker %p initialized with %u
b
ps and max carry %u\n",
+ "Tracker %p initialized with %u
B
ps and max carry %u\n",
av,
(unsigned int) av->available_bytes_per_s__,
(unsigned int) max_carry_s);
av,
(unsigned int) av->available_bytes_per_s__,
(unsigned int) max_carry_s);
@@
-175,7
+175,7
@@
update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
uint64_t max_carry;
now = GNUNET_TIME_absolute_get ();
uint64_t max_carry;
now = GNUNET_TIME_absolute_get ();
- delta_time = now.
value - av->last_update__.
value;
+ delta_time = now.
abs_value - av->last_update__.abs_
value;
delta_avail = (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 500LL) / 1000LL;
av->consumption_since_last_update__ -= delta_avail;
av->last_update__ = now;
delta_avail = (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 500LL) / 1000LL;
av->consumption_since_last_update__ -= delta_avail;
av->last_update__ = now;
@@
-183,16
+183,21
@@
update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
{
left_bytes = - av->consumption_since_last_update__;
max_carry = av->available_bytes_per_s__ * av->max_carry_s__;
{
left_bytes = - av->consumption_since_last_update__;
max_carry = av->available_bytes_per_s__ * av->max_carry_s__;
+ if (max_carry < GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ max_carry = GNUNET_SERVER_MAX_MESSAGE_SIZE;
if (max_carry > left_bytes)
if (max_carry > left_bytes)
- av->consumption_since_last_update__ = -max_carry;
+ av->consumption_since_last_update__ = -left_bytes;
+ else
+ av->consumption_since_last_update__ = -max_carry;
}
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
}
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tracker %p updated, have %u
bps
last update was %llu ms ago\n",
+ "Tracker %p updated, have %u
Bps,
last update was %llu ms ago\n",
av,
(unsigned int) av->available_bytes_per_s__,
av,
(unsigned int) av->available_bytes_per_s__,
- (unsigned long long)
(now.value - av->last_update__.value)
);
+ (unsigned long long)
delta_time
);
#endif
#endif
+
}
}
@@
-285,13
+290,13
@@
GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av,
#endif
return GNUNET_TIME_UNIT_ZERO;
}
#endif
return GNUNET_TIME_UNIT_ZERO;
}
- ret.value = 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__;
+ ret.
rel_
value = 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__;
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tracker %p delay for %u bytes is %llu ms\n",
av,
(unsigned int) size,
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tracker %p delay for %u bytes is %llu ms\n",
av,
(unsigned int) size,
- (unsigned long long) ret.value);
+ (unsigned long long) ret.
rel_
value);
#endif
return ret;
}
#endif
return ret;
}
@@
-318,7
+323,7
@@
GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av)
used = av->consumption_since_last_update__;
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
used = av->consumption_since_last_update__;
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tracker %p available bandwi
th is %lld m
s\n",
+ "Tracker %p available bandwi
dth is %lld byte
s\n",
av,
(long long) (int64_t) (avail - used));
#endif
av,
(long long) (int64_t) (avail - used));
#endif
@@
-342,7
+347,7
@@
GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av,
new_limit = ntohl (bytes_per_second_limit.value__);
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
new_limit = ntohl (bytes_per_second_limit.value__);
#if DEBUG_BANDWIDTH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tracker %p bandwi
th changed to %u b
ps\n",
+ "Tracker %p bandwi
dth changed to %u B
ps\n",
av,
(unsigned int) new_limit);
#endif
av,
(unsigned int) new_limit);
#endif