From: Christopher Faulet Date: Thu, 31 Aug 2017 15:52:09 +0000 (+0200) Subject: MINOR: fd: Move (de)allocation of fdtab and fdinfo in (de)init_pollers X-Git-Tag: v1.8-dev3~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63fe65277a74101431a898703ebe73d71a1b573d;p=thirdparty%2Fhaproxy.git MINOR: fd: Move (de)allocation of fdtab and fdinfo in (de)init_pollers This will be useful for the threads support integration. --- diff --git a/src/fd.c b/src/fd.c index c197557be1..8dab4977a9 100644 --- a/src/fd.c +++ b/src/fd.c @@ -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; } /* diff --git a/src/haproxy.c b/src/haproxy.c index 488a076177..fc99225c06 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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;