MINOR: fd: report an error message when failing initial allocations
When starting with a huge maxconn (say 1 billion), the only error seen
is "No polling mechanism available". This doesn't help at all to resolve
the problem. Let's add specific alerts for the failed mallocs. Now we can
get this instead:
[ALERT] 286/154439 (23408) : Not enough memory to allocate 2000000033 entries for fdtab!
This may be backported as far as 2.0 as it helps debugging bad configurations.
(cherry picked from commit 7c9f756dcc51b9974d5e81116e1d8a34a6152040)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2e0c88d6418bd90877a30ef5db414fe412f5a1b6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a0eeba891310ce85f2f348dd42c0fafec2e0e511)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/fd.c b/src/fd.c
index 3d361e8..d54af91 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -634,14 +634,20 @@
int p;
struct poller *bp;
- if ((fdtab = calloc(global.maxsock, sizeof(struct fdtab))) == NULL)
+ if ((fdtab = calloc(global.maxsock, sizeof(struct fdtab))) == NULL) {
+ ha_alert("Not enough memory to allocate %d entries for fdtab!\n", global.maxsock);
goto fail_tab;
+ }
- if ((polled_mask = calloc(global.maxsock, sizeof(unsigned long))) == NULL)
+ if ((polled_mask = calloc(global.maxsock, sizeof(unsigned long))) == NULL) {
+ ha_alert("Not enough memory to allocate %d entries for polled_mask!\n", global.maxsock);
goto fail_polledmask;
+ }
- if ((fdinfo = calloc(global.maxsock, sizeof(struct fdinfo))) == NULL)
+ if ((fdinfo = calloc(global.maxsock, sizeof(struct fdinfo))) == NULL) {
+ ha_alert("Not enough memory to allocate %d entries for fdinfo!\n", global.maxsock);
goto fail_info;
+ }
fd_cache.first = fd_cache.last = -1;
update_list.first = update_list.last = -1;