From: Willy Tarreau Date: Tue, 13 Oct 2020 13:45:07 +0000 (+0200) Subject: MINOR: fd: report an error message when failing initial allocations X-Git-Tag: v2.3-dev7~53 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=7c9f756dcc51b9974d5e81116e1d8a34a6152040;p=haproxy-3.0.git 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. --- diff --git a/src/fd.c b/src/fd.c index 2c1dcef..79a9ec8 100644 --- a/src/fd.c +++ b/src/fd.c @@ -665,14 +665,20 @@ int init_pollers() int p; struct poller *bp; - if ((fdtab = calloc(global.maxsock, sizeof(*fdtab))) == NULL) + if ((fdtab = calloc(global.maxsock, sizeof(*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(*polled_mask))) == NULL) + 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); goto fail_polledmask; + } - if ((fdinfo = calloc(global.maxsock, sizeof(*fdinfo))) == NULL) + if ((fdinfo = calloc(global.maxsock, sizeof(*fdinfo))) == NULL) { + ha_alert("Not enough memory to allocate %d entries for fdinfo!\n", global.maxsock); goto fail_info; + } update_list.first = update_list.last = -1;