[PATCH] Avoid multiple bind for the same address during config test

i at morfi.ru i at morfi.ru
Fri Apr 12 13:36:09 UTC 2019


# HG changeset patch
# User Andrey Kolyshkin <a.kolyshkin at corp.vk.com>
# Date 1555075759 -10800
#      Fri Apr 12 16:29:19 2019 +0300
# Node ID 549f07c848d82ef152ed54f31b25dcfe89452a66
# Parent  5155d0296a5ef9841f035920527ffdb771076b44
Avoid multiple bind for the same address during config test

If reuseport is specified in the config, then during config test nginx makes multiple calls to the bind function for the same address.
It causes a problem when large number of connections goes to the server and bind (inet_csk_bind_conflict) loads cpu multiple times.
After fixing, bind is called only 1 time per address while testing of the config.

diff -r 5155d0296a5e -r 549f07c848d8 src/core/ngx_connection.c
--- a/src/core/ngx_connection.c	Tue Apr 09 16:00:30 2019 +0300
+++ b/src/core/ngx_connection.c	Fri Apr 12 16:29:19 2019 +0300
@@ -104,7 +104,7 @@
     ngx_core_conf_t  *ccf;
     ngx_listening_t   ols;
 
-    if (!ls->reuseport || ls->worker != 0) {
+    if (!ls->reuseport || ls->worker != 0 || ngx_test_config) {
         return NGX_OK;
     }
 


More information about the nginx-devel mailing list