diff options
Diffstat (limited to 'src/journal/journald-rate-limit.c')
-rw-r--r-- | src/journal/journald-rate-limit.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/journal/journald-rate-limit.c b/src/journal/journald-rate-limit.c index 4b76221527..6d779d2966 100644 --- a/src/journal/journald-rate-limit.c +++ b/src/journal/journald-rate-limit.c @@ -56,7 +56,7 @@ struct JournalRateLimitGroup { char *id; JournalRateLimitPool pools[POOLS_MAX]; - unsigned hash; + unsigned long hash; LIST_FIELDS(JournalRateLimitGroup, bucket); LIST_FIELDS(JournalRateLimitGroup, lru); @@ -70,6 +70,8 @@ struct JournalRateLimit { JournalRateLimitGroup *lru, *lru_tail; unsigned n_groups; + + uint8_t hash_key[16]; }; JournalRateLimit *journal_rate_limit_new(usec_t interval, unsigned burst) { @@ -84,6 +86,8 @@ JournalRateLimit *journal_rate_limit_new(usec_t interval, unsigned burst) { r->interval = interval; r->burst = burst; + random_bytes(r->hash_key, sizeof(r->hash_key)); + return r; } @@ -152,7 +156,7 @@ static JournalRateLimitGroup* journal_rate_limit_group_new(JournalRateLimit *r, if (!g->id) goto fail; - g->hash = string_hash_func(g->id); + g->hash = string_hash_func(g->id, r->hash_key); journal_rate_limit_vacuum(r, ts); @@ -199,7 +203,7 @@ static unsigned burst_modulate(unsigned burst, uint64_t available) { } int journal_rate_limit_test(JournalRateLimit *r, const char *id, int priority, uint64_t available) { - unsigned h; + unsigned long h; JournalRateLimitGroup *g; JournalRateLimitPool *p; unsigned burst; @@ -217,7 +221,7 @@ int journal_rate_limit_test(JournalRateLimit *r, const char *id, int priority, u ts = now(CLOCK_MONOTONIC); - h = string_hash_func(id); + h = string_hash_func(id, r->hash_key); g = r->buckets[h % BUCKETS_MAX]; LIST_FOREACH(bucket, g, g) |