From: Michael R Sweet Date: Fri, 20 Sep 2024 15:33:48 +0000 (-0400) Subject: Check for negative max-fds limit and set to 65535. Fixes a test hang. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c5ff996c2012511a427d5eb188ea4c42f83a2bd;p=thirdparty%2Fcups.git Check for negative max-fds limit and set to 65535. Fixes a test hang. --- diff --git a/scheduler/client.c b/scheduler/client.c index 9c2f1ef814..ab3d835e25 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -68,7 +68,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */ * Make sure we don't have a full set of clients already... */ - if (cupsArrayGetCount(Clients) == MaxClients) + if (MaxClients && cupsArrayGetCount(Clients) >= MaxClients) return; cupsdSetBusyState(1); diff --git a/scheduler/main.c b/scheduler/main.c index 62fa8e8dd0..be2e5f13f9 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -507,10 +507,16 @@ main(int argc, /* I - Number of command-line args */ * to the number of TCP port number values (64k-1)... */ - getrlimit(RLIMIT_NOFILE, &limit); - - if ((MaxFDs = limit.rlim_max) > 65535) + if (getrlimit(RLIMIT_NOFILE, &limit)) + { + // This should never happen but if it does choose a safe upper limit... + perror("getrlimit"); + MaxFDs = 256; + } + else if ((MaxFDs = limit.rlim_max) > 65535 || MaxFDs <= 0) + { MaxFDs = 65535; + } limit.rlim_cur = (rlim_t)MaxFDs;