MINOR: fd: Move (de)allocation of fdtab and fdinfo in (de)init_pollers

This will be useful for the threads support integration.
This commit is contained in:
Christopher Faulet 2017-08-31 17:52:09 +02:00 committed by Willy Tarreau
parent d82b180d6b
commit 63fe65277a
2 changed files with 16 additions and 12 deletions

View File

@ -270,10 +270,16 @@ int init_pollers()
int p;
struct poller *bp;
if ((fd_cache = calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
if ((fdtab = calloc(global.maxsock, sizeof(struct fdtab))) == NULL)
goto fail_tab;
if ((fdinfo = calloc(global.maxsock, sizeof(struct fdinfo))) == NULL)
goto fail_info;
if ((fd_cache = calloc(global.maxsock, sizeof(*fd_cache))) == NULL)
goto fail_cache;
if ((fd_updt = calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
if ((fd_updt = calloc(global.maxsock, sizeof(*fd_updt))) == NULL)
goto fail_updt;
do {
@ -295,6 +301,10 @@ int init_pollers()
fail_updt:
free(fd_cache);
fail_cache:
free(fdinfo);
fail_info:
free(fdtab);
fail_tab:
return 0;
}
@ -312,11 +322,10 @@ void deinit_pollers() {
if (bp && bp->pref)
bp->term(bp);
}
free(fd_updt);
free(fd_cache);
fd_updt = NULL;
fd_cache = NULL;
free(fd_updt); fd_updt = NULL;
free(fd_cache); fd_cache = NULL;
free(fdinfo); fdinfo = NULL;
free(fdtab); fdtab = NULL;
}
/*

View File

@ -1718,9 +1718,6 @@ static void init(int argc, char **argv)
exit(1);
}
fdinfo = calloc(1, sizeof(struct fdinfo) * (global.maxsock));
fdtab = calloc(1, sizeof(struct fdtab) * (global.maxsock));
/*
* Note: we could register external pollers here.
* Built-in pollers have been registered before main().
@ -2118,8 +2115,6 @@ void deinit(void)
free(global.pidfile); global.pidfile = NULL;
free(global.node); global.node = NULL;
free(global.desc); global.desc = NULL;
free(fdinfo); fdinfo = NULL;
free(fdtab); fdtab = NULL;
free(oldpids); oldpids = NULL;
free(global_listener_queue_task); global_listener_queue_task = NULL;