diff options
| author | yangwei <[email protected]> | 2024-04-11 09:51:34 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-04-12 00:42:48 +0800 |
| commit | 12abc0a910c188b3b4e92fdbdfc6b81a6721622e (patch) | |
| tree | 56fc7eb228ed640e9a0bc7d53572f15d977ef628 /src/support | |
| parent | 3bb30afc483bc0297b7b88901818021d3045d1d5 (diff) | |
✨ feat(sapp metric update): 新增open和timeout速率统计,暂时关闭offload统计
Diffstat (limited to 'src/support')
| -rw-r--r-- | src/support/token_bucket/token_bucket.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/support/token_bucket/token_bucket.c b/src/support/token_bucket/token_bucket.c index eeedba4..580e8cb 100644 --- a/src/support/token_bucket/token_bucket.c +++ b/src/support/token_bucket/token_bucket.c @@ -32,7 +32,7 @@ void token_bucket_free(struct token_bucket *t) int token_bucket_consume(struct token_bucket *t, long long tokens, long long now_ms) { - if (t == NULL || tokens <= 0 || now_ms <= 0)return 0; + if (t == NULL || tokens <= 0 || now_ms <= 0)return 1; if (tokens > t->CBS)return 0; if (now_ms < t->last_refill_timestamp_ms) return 0; @@ -42,7 +42,7 @@ int token_bucket_consume(struct token_bucket *t, long long tokens, long long now if(delta_ms > DEFALUT_REFILL_INTERVAL_MS && refill > 0) { - t->tokens += MIN(refill, t->CBS); + t->tokens = MIN(refill, t->CBS); t->last_refill_timestamp_ms = now_ms; } |
