@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+ long long int now);
void token_bucket_wait_at(struct token_bucket *, unsigned int n,
const char *where);
#define token_bucket_wait(bucket, n) \
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
* if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
* removed) . */
bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+ long long int now)
{
if (tb->tokens < n) {
- long long int now = time_msec();
if (now > tb->last_fill) {
unsigned long long int elapsed_ull
= (unsigned long long int) now - tb->last_fill;
@@ -1321,7 +1321,8 @@ vlog_should_drop(const struct vlog_module *module, enum vlog_level level,
}
ovs_mutex_lock(&rl->mutex);
- if (!token_bucket_withdraw(&rl->token_bucket, VLOG_MSG_TOKENS)) {
+ if (!token_bucket_withdraw(&rl->token_bucket, VLOG_MSG_TOKENS,
+ time_msec())) {
time_t now = time_now();
if (!rl->n_dropped) {
rl->first_dropped = now;
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
static bool
get_token(struct pinsched *ps)
{
- return token_bucket_withdraw(&ps->token_bucket, 1000);
+ return token_bucket_withdraw(&ps->token_bucket, 1000, time_msec());
}
void