CLEANUP: fd: make use of ha_aligned_alloc() for the fdtab

We've forcefully aligned the fdtab in commit 97ea9c49f1 ("BUG/MEDIUM:
fd: always align fdtab[] to 64 bytes"), but now we don't need such hacks
anymore thanks to ha_aligned_alloc(). Let's use it and get rid of
fdtab_addr.
This commit is contained in:
Willy Tarreau 2025-08-11 18:55:09 +02:00
parent 746e77d000
commit 5e2837cfb4

View File

@ -117,7 +117,6 @@ THREAD_LOCAL int poller_rd_pipe = -1; // Pipe to wake the thread
int poller_wr_pipe[MAX_THREADS] __read_mostly; // Pipe to wake the threads
volatile int ha_used_fds = 0; // Number of FD we're currently using
static struct fdtab *fdtab_addr; /* address of the allocated area containing fdtab */
/* adds fd <fd> to fd list <list> if it was not yet in it */
void fd_add_to_fd_list(volatile struct fdlist *list, int fd)
@ -1166,14 +1165,12 @@ int init_pollers()
int p;
struct poller *bp;
if ((fdtab_addr = calloc(1, global.maxsock * sizeof(*fdtab) + 64)) == NULL) {
/* always provide an aligned fdtab */
if ((fdtab = ha_aligned_zalloc(64, global.maxsock * sizeof(*fdtab))) == NULL) {
ha_alert("Not enough memory to allocate %d entries for fdtab!\n", global.maxsock);
goto fail_tab;
}
vma_set_name(fdtab_addr, global.maxsock * sizeof(*fdtab) + 64, "fd", "fdtab_addr");
/* always provide an aligned fdtab */
fdtab = (struct fdtab*)((((size_t)fdtab_addr) + 63) & -(size_t)64);
vma_set_name(fdtab, global.maxsock * sizeof(*fdtab), "fd", "fdtab");
if ((polled_mask = calloc(global.maxsock, sizeof(*polled_mask))) == NULL) {
ha_alert("Not enough memory to allocate %d entries for polled_mask!\n", global.maxsock);
@ -1214,7 +1211,7 @@ int init_pollers()
fail_info:
free(polled_mask);
fail_polledmask:
free(fdtab_addr);
ha_aligned_free(fdtab);
fail_tab:
return 0;
}
@ -1235,7 +1232,7 @@ void deinit_pollers() {
}
ha_free(&fdinfo);
ha_free(&fdtab_addr);
ha_aligned_free(fdtab);
ha_free(&polled_mask);
}