From a1335d672bc2cc2b1459908c91a3e8860dd40bb8 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 16 Nov 2020 17:10:57 +0000 Subject: [PATCH] osx: work around some big sur machines getting MAX_LONG ulimit -n --- lib/core/context.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/core/context.c b/lib/core/context.c index 33f563be3..7a20fefaf 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -706,7 +706,18 @@ lws_create_context(const struct lws_context_creation_info *info) #if defined(WIN32) || defined(_WIN32) || defined(LWS_AMAZON_RTOS) || defined(LWS_ESP_PLATFORM) context->max_fds = getdtablesize(); #else - context->max_fds = sysconf(_SC_OPEN_MAX); + { + long l = sysconf(_SC_OPEN_MAX); + + context->max_fds = 2560; + + if (l > 10000000) + lwsl_warn("%s: unreasonable ulimit -n workaround\n", + __func__); + else + if (l != -1l) + context->max_fds = (int)l; + } #endif if (context->max_fds < 0) { lwsl_err("%s: problem getting process max files\n",