Skip to content

Commit

Permalink
Check for negative max-fds limit and set to 65535. Fixes a test hang.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Sep 20, 2024
1 parent ca3c40b commit 0c5ff99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scheduler/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions scheduler/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0c5ff99

Please sign in to comment.