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)
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);
fail_info:
free(polled_mask);
fail_polledmask:
- free(fdtab_addr);
+ ha_aligned_free(fdtab);
fail_tab:
return 0;
}
}
ha_free(&fdinfo);
- ha_free(&fdtab_addr);
+ ha_aligned_free(fdtab);
ha_free(&polled_mask);
}