]> git.kaiwu.me - nginx.git/commitdiff
Events: added configuration check on the number of connections.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 12 Jul 2018 16:50:07 +0000 (19:50 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 12 Jul 2018 16:50:07 +0000 (19:50 +0300)
There should be at least one worker connection for each listening socket,
plus an additional connection for channel between worker and master,
or starting worker processes will fail.

src/event/ngx_event.c

index a18b1132c934aaa31d3a81c47ed7fac474e49568..69c55d7a0602670cf94bf2f6d9ea5ee75ca9a599 100644 (file)
@@ -421,6 +421,21 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
         return NGX_CONF_ERROR;
     }
 
+    if (cycle->connection_n < cycle->listening.nelts + 1) {
+
+        /*
+         * there should be at least one connection for each listening
+         * socket, plus an additional connection for channel
+         */
+
+        ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+                      "%ui worker_connections are not enough "
+                      "for %ui listening sockets",
+                      cycle->connection_n, cycle->listening.nelts);
+
+        return NGX_CONF_ERROR;
+    }
+
 #if (NGX_HAVE_REUSEPORT)
 
     ls = cycle->listening.elts;