Having the caller of token_bucket_wait() indicated in the log messages
makes debugging easier.
Signed-off-by: Jarno Rajahalme
---
include/openvswitch/token-bucket.h | 5 -
lib/token-bucket.c | 7 ---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/openvswitch/token-bucket.h
b/include/openvswitch/token-bucket.h
index bbcde84..6bb6040 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -37,6 +37,9 @@ void token_bucket_init(struct token_bucket *,
void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
-void token_bucket_wait(struct token_bucket *, unsigned int n);
+void token_bucket_wait_at(struct token_bucket *, unsigned int n,
+ const char *where);
+#define token_bucket_wait(bucket, n)\
+token_bucket_wait_at(bucket, n, OVS_SOURCE_LOCATOR)
#endif /* token-bucket.h */
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index be90453..29f5165 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -85,12 +85,13 @@ token_bucket_withdraw(struct token_bucket *tb, unsigned int
n)
/* Causes the poll loop to wake up when at least 'n' tokens will be available
* for withdrawal from 'tb'. */
void
-token_bucket_wait(struct token_bucket *tb, unsigned int n)
+token_bucket_wait_at(struct token_bucket *tb, unsigned int n,
+ const char *where)
{
if (tb->tokens >= n) {
-poll_immediate_wake();
+poll_immediate_wake_at(where);
} else {
unsigned int need = n - tb->tokens;
-poll_timer_wait_until(tb->last_fill + need / tb->rate + 1);
+poll_timer_wait_until_at(tb->last_fill + need / tb->rate + 1, where);
}
}
--
2.1.4
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev