]> git.kaiwu.me - nginx.git/commitdiff
Disabled cloning of sockets without master process (ticket #2403).
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 23 Nov 2022 20:12:04 +0000 (23:12 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 23 Nov 2022 20:12:04 +0000 (23:12 +0300)
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.

src/event/ngx_event.c

index 47229b507337716d708dd44868282182b6222a93..77b07f6e16f792bfb4a53080b4ed2b3e12fed4cf 100644 (file)
@@ -416,6 +416,7 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
 {
 #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, void *conf)
 
 #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++) {