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 c197557..8dab497 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -270,10 +270,16 @@
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 @@
fail_updt:
free(fd_cache);
fail_cache:
+ free(fdinfo);
+ fail_info:
+ free(fdtab);
+ fail_tab:
return 0;
}
@@ -312,11 +322,10 @@
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 488a076..fc99225 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1718,9 +1718,6 @@
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 @@
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;