[PATCH] Disabled cloning of sockets without master process (ticket #2403)

Maxim Dounin mdounin at mdounin.ru
Thu Nov 24 18:25:37 UTC 2022


Hello!

On Wed, Nov 23, 2022 at 05:56:01PM +0400, Sergey Kandaurov wrote:

> 
> > On 30 Oct 2022, at 06:41, Maxim Dounin <mdounin at mdounin.ru> wrote:
> > 
> > # HG changeset patch
> > # User Maxim Dounin <mdounin at mdounin.ru>
> > # Date 1667097682 -10800
> > #      Sun Oct 30 05:41:22 2022 +0300
> > # Node ID b73d95226c84b93e51f23f7b35782d98d3b516b9
> > # Parent  55bcf8dc4ee35ccf40f5b8a7cffde63e7edb9494
> > Disabled cloning of sockets without master process (ticket #2403).
> > 
> > Cloning of listening sockets for each worker process does not make sense
> > when working without master process, and causes some of the connections
> > not to be accepted if worker_processes is set to more than one and there
> > are listening sockets configured with the reuseport flag.  Fix is to
> > disable cloning when master process is disabled.
> > 
> > diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
> > --- a/src/event/ngx_event.c
> > +++ b/src/event/ngx_event.c
> > @@ -416,6 +416,7 @@ ngx_event_init_conf(ngx_cycle_t *cycle, 
> > {
> > #if (NGX_HAVE_REUSEPORT)
> >     ngx_uint_t        i;
> > +    ngx_core_conf_t  *ccf;
> >     ngx_listening_t  *ls;
> > #endif
> > 
> > @@ -442,7 +443,9 @@ ngx_event_init_conf(ngx_cycle_t *cycle, 
> > 
> > #if (NGX_HAVE_REUSEPORT)
> > 
> > -    if (!ngx_test_config) {
> > +    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
> > +
> > +    if (!ngx_test_config && ccf->master) {
> > 
> >         ls = cycle->listening.elts;
> >         for (i = 0; i < cycle->listening.nelts; i++) {
> 
> Looks good.

Pushed to http://mdounin.ru/hg/nginx, thanks.

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



More information about the nginx-devel mailing list