Skip to content

Commit

Permalink
Remap shared memory lookup tables after they have been resized
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Nov 18, 2024
1 parent 64cf486 commit 81d06bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@ static void remap_shm(void)
realloc_shm(&shm_strings, counters->strings_MAX, sizeof(char), false);
// strings are not exposed by a global pointer

realloc_shm(&shm_domains_lookup, counters->domains_lookup_MAX, sizeof(struct lookup_table), false);
domains_lookup = (struct lookup_table*)shm_domains_lookup.ptr;

realloc_shm(&shm_clients_lookup, counters->clients_lookup_MAX, sizeof(struct lookup_table), false);
clients_lookup = (struct lookup_table*)shm_clients_lookup.ptr;

realloc_shm(&shm_dns_cache_lookup, counters->dns_cache_lookup_MAX, sizeof(struct lookup_table), false);
dns_cache_lookup = (struct lookup_table*)shm_dns_cache_lookup.ptr;

// Update local counter to reflect that we absorbed this change
local_shm_counter = shmSettings->global_shm_counter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static bool create_shm(const char *name, SharedMemory *sharedMemory, const size_
/// \param sharedMemory the shared memory struct
/// \param size1 the new size (factor 1)
/// \param size2 the new size (factor 2)
/// \param resize whether the object should be resized or only remapped
/// \param resize whether the object should be resized (true) or only remapped (false)
/// \return if reallocation was successful
static bool realloc_shm(SharedMemory *sharedMemory, const size_t size1, const size_t size2, const bool resize);

Expand Down

0 comments on commit 81d06bf

Please sign in to comment.