[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Silently lower nmerge; don't (sometimes incorrectly) range-c
Re: [PATCH] Silently lower nmerge; don't (sometimes incorrectly) range-check it.
Tue, 10 Mar 2009 00:03:26 +0000
Thunderbird 184.108.40.206 (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?