From beb84401c6698dfe937178d8ac8fa38505468dbb Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 20 Jun 2024 08:51:26 -0400 Subject: [PATCH] Limit the maximum number of file descriptors to 64k-1 (Issue #989) --- CHANGES.md | 13 ++++++++++--- scheduler/main.c | 15 ++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4a2e25d5d6..64baa4fae0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,15 @@ -CHANGES - OpenPrinting CUPS 2.4.10 - (2024-06-18) -================================================ +CHANGES - OpenPrinting CUPS +=========================== + + +Changes in CUPS v2.4.11 (YYYY-MM-DD) +------------------------------------ + +- Updated the maximum file descriptor limit for `cupsd` to 64k-1 (Issue #989) + Changes in CUPS v2.4.10 (2024-06-18) ------------------------------ +------------------------------------ - Fixed error handling when reading a mixed `1setOf` attribute. - Fixed scheduler start if there is only domain socket to listen on (Issue #985) diff --git a/scheduler/main.c b/scheduler/main.c index ae2409e02a..c91f47710e 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -519,22 +519,19 @@ main(int argc, /* I - Number of command-line args */ #endif /* HAVE_DBUS_THREADS_INIT */ /* - * Set the maximum number of files... + * Set the maximum number of files, which for practical reasons can be limited + * to the number of TCP port number values (64k-1)... */ getrlimit(RLIMIT_NOFILE, &limit); #if !defined(HAVE_POLL) && !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE) - if (limit.rlim_max > FD_SETSIZE) + if ((MaxFDs = limit.rlim_max) > FD_SETSIZE) MaxFDs = FD_SETSIZE; - else -#endif /* !HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE */ -#ifdef RLIM_INFINITY - if (limit.rlim_max == RLIM_INFINITY) - MaxFDs = 16384; - else +#else + if ((MaxFDs = limit.rlim_max) > 65535) + MaxFDs = 65535; #endif /* RLIM_INFINITY */ - MaxFDs = limit.rlim_max; limit.rlim_cur = (rlim_t)MaxFDs; -- 2.47.2