diff options
author | Lukáš Ondráček <lukas.ondracek@nic.cz> | 2024-10-01 15:13:21 +0200 |
---|---|---|
committer | Lukáš Ondráček <lukas.ondracek@nic.cz> | 2024-10-01 15:13:21 +0200 |
commit | 22a8db5c0d6c583088fa6aa7460be2a69ad9c223 (patch) | |
tree | 2c5b50e9794b839b58fbd6ae69a69ebd3b7d61bf /daemon/ratelimiting.c | |
parent | lib/log: add [defer ] group (diff) | |
download | knot-resolver-22a8db5c0d6c583088fa6aa7460be2a69ad9c223.tar.xz knot-resolver-22a8db5c0d6c583088fa6aa7460be2a69ad9c223.zip |
daemon/mmapped: remove padding from header where used
Diffstat (limited to '')
-rw-r--r-- | daemon/ratelimiting.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/daemon/ratelimiting.c b/daemon/ratelimiting.c index cd15dc8c..676fde57 100644 --- a/daemon/ratelimiting.c +++ b/daemon/ratelimiting.c @@ -42,7 +42,6 @@ int ratelimiting_init(const char *mmap_file, size_t capacity, uint32_t instant_l for (size_t c = capacity - 1; c > 0; c >>= 1) capacity_log++; size_t size = offsetof(struct ratelimiting, kru) + KRU.get_size(capacity_log); - size_t header_size = offsetof(struct ratelimiting, v4_prices); struct ratelimiting header = { .capacity = capacity, @@ -52,6 +51,14 @@ int ratelimiting_init(const char *mmap_file, size_t capacity, uint32_t instant_l .using_avx2 = using_avx2() }; + size_t header_size = offsetof(struct ratelimiting, using_avx2) + sizeof(header.using_avx2); + kr_assert(header_size == + sizeof(header.capacity) + + sizeof(header.instant_limit) + + sizeof(header.rate_limit) + + sizeof(header.tc_limit) + + sizeof(header.using_avx2)); // no undefined padding inside + int ret = mmapped_init(&ratelimiting_mmapped, mmap_file, size, &header, header_size); if (ret == MMAPPED_WAS_FIRST) { kr_log_info(SYSTEM, "Initializing rate-limiting...\n"); |