[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Silently lower nmerge; don't (sometimes incorrectly) range-c
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] Silently lower nmerge; don't (sometimes incorrectly) range-check it. |
Date: |
Tue, 10 Mar 2009 00:03:26 +0000 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
> +/* Lower NMERGE if necessary, to fit within operating system limits. */
> +static void
> +lower_nmerge_if_necessary (void)
> +{
> + /* How many file descriptors are needed per input and output file. */
> + int fds_per_file = (compress_program ? 3 : 1);
> +
> + /* How many file descriptors we think we'll need, total. It
> + obviously can't exceed INT_MAX. */
> + int fds_needed = (nmerge <= INT_MAX / fds_per_file - 1
> + ? (nmerge + 1) * fds_per_file
> + : INT_MAX);
would RLIMIT_NOFILE be a better limit than INT_MAX if available?
cheers,
Pádraig.