[PATCH] Fix ngx_max_sockets variable, set actual value after use setrlimit(RLIMIT_NOFILE)

Maxim Dounin mdounin at mdounin.ru
Thu Oct 24 15:53:35 UTC 2019


Hello!

On Thu, Oct 24, 2019 at 01:38:38PM +0000, i at morfi.ru wrote:

> # HG changeset patch
> # User Andrey Kolyshkin <i at morfi.ru>
> # Date 1571924112 -10800
> #      Thu Oct 24 16:35:12 2019 +0300
> # Node ID dfae615e676214a83b91abfbb51c334cfb1ecfdd
> # Parent  89adf49fe76ada86d84e2af8f5cee9ca8c3dca19
> Fix ngx_max_sockets variable, set actual value after use setrlimit(RLIMIT_NOFILE)
> 
> diff -r 89adf49fe76a -r dfae615e6762 src/os/unix/ngx_process_cycle.c
> --- a/src/os/unix/ngx_process_cycle.c	Mon Oct 21 20:22:30 2019 +0300
> +++ b/src/os/unix/ngx_process_cycle.c	Thu Oct 24 16:35:12 2019 +0300
> @@ -811,6 +811,8 @@
>              ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
>                            "setrlimit(RLIMIT_NOFILE, %i) failed",
>                            ccf->rlimit_nofile);
> +        } else {
> +            ngx_max_sockets = ccf->rlimit_nofile;
>          }
>      }
>  

I'm not what the intended semantics of the ngx_max_sockets 
variable is, but given that it is not used - I don't think it 
matters, and the existing semantics of being rlimit_nofile at the 
time of nginx start is good enough.

On the other hand, the change suggested breaks any possible 
intended semantics, as successful setrlimit() does not mean that 
the specified limit was actually applied.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list