From 85d55c850de6bc1c3dfbdf346dc086745f124454 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 19 Mar 2022 17:09:55 +0000 Subject: [PATCH] Feature: Warn about FD_SETSIZE being too small --- src/admin.c | 8 ++++++++ src/cfgfile.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/admin.c b/src/admin.c index 7878f73b..72270dd7 100644 --- a/src/admin.c +++ b/src/admin.c @@ -33,6 +33,10 @@ #include #endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + #ifdef HAVE_OPENSSL #include #endif @@ -1836,6 +1840,10 @@ static void command_version (client_t *client, source_t *source, adm reportxml_helper_add_value_string(resource, "version", ICECAST_VERSION_STRING); reportxml_helper_add_value_int(resource, "address-bits", sizeof(void*)*8); +#ifdef HAVE_SYS_SELECT_H + reportxml_helper_add_value_int(resource, "fd-set-size", FD_SETSIZE); +#endif + #ifdef HAVE_GETHOSTNAME if (true) { char hostname[80]; diff --git a/src/cfgfile.c b/src/cfgfile.c index 94f2a0c4..272ce316 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -25,6 +25,9 @@ #ifndef _WIN32 #include #endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif #include #include #include @@ -1045,6 +1048,13 @@ int config_parse_file(const char *filename, ice_config_t *configuration) ICECAST_LOG_ERROR("Client limit (%i) is too small for given source limit (%i)", configuration->client_limit, configuration->source_limit); } +#ifndef HAVE_POLL + if (configuration->client_limit > (FD_SETSIZE - 32)) { + configuration->config_problems |= CONFIG_PROBLEM_VALIDATION; + ICECAST_LOG_ERROR("Client limit (%i) is too big for FD_SETSIZE (%i)", configuration->client_limit, FD_SETSIZE); + } +#endif + return 0; }