From 96a330d5e594025280d76966f09862764a1e6b2c Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 20 Sep 2024 11:40:28 -0400 Subject: [PATCH] Mirror fix for max-fds from 2.5. --- scheduler/client.c | 2 +- scheduler/main.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scheduler/client.c b/scheduler/client.c index d47b84d06..233f9017d 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -80,7 +80,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */ * Make sure we don't have a full set of clients already... */ - if (cupsArrayCount(Clients) == MaxClients) + if (MaxClients > 0 && cupsArrayCount(Clients) >= MaxClients) return; cupsdSetBusyState(1); diff --git a/scheduler/main.c b/scheduler/main.c index c91f47710..a939cdae1 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -523,13 +523,14 @@ main(int argc, /* I - Number of command-line args */ * to the number of TCP port number values (64k-1)... */ + limit.rlim_max = 0; getrlimit(RLIMIT_NOFILE, &limit); #if !defined(HAVE_POLL) && !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE) - if ((MaxFDs = limit.rlim_max) > FD_SETSIZE) + if ((MaxFDs = limit.rlim_max) > FD_SETSIZE || MaxFDs <= 0) MaxFDs = FD_SETSIZE; #else - if ((MaxFDs = limit.rlim_max) > 65535) + if ((MaxFDs = limit.rlim_max) > 65535 || MaxFDs <= 0) MaxFDs = 65535; #endif /* RLIM_INFINITY */