]> git.kaiwu.me - nginx.git/commitdiff
Simplified ngx_http_init_listening().
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 20 May 2015 12:51:28 +0000 (15:51 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 20 May 2015 12:51:28 +0000 (15:51 +0300)
There is no need to set "i" to 0, as it's expected to be 0 assuming
the bindings are properly sorted, and we already rely on this when
explicitly set hport->naddrs to 1.  Remaining conditional code is
replaced with identical "hport->naddrs = i + 1".

Identical modifications are done in the mail and stream modules,
in the ngx_mail_optimize_servers() and ngx_stream_optimize_servers()
functions, respectively.

No functional changes.

src/http/ngx_http.c
src/mail/ngx_mail.c
src/stream/ngx_stream.c

index 924c4b548964c54b632ed69aeea530699088a458..adb4b6f368cc7343424211f3631e112d8f0eb42d 100644 (file)
@@ -1719,13 +1719,7 @@ ngx_http_init_listening(ngx_conf_t *cf, ngx_http_conf_port_t *port)
 
         ls->servers = hport;
 
-        if (i == last - 1) {
-            hport->naddrs = last;
-
-        } else {
-            hport->naddrs = 1;
-            i = 0;
-        }
+        hport->naddrs = i + 1;
 
         switch (ls->sockaddr->sa_family) {
 
index 48ce2861759cfb66e00a8f2a051d9179f517d7c1..f10f08c5f6cd8b1bc9bb349e9395e190fc2fc768 100644 (file)
@@ -392,13 +392,7 @@ ngx_mail_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports)
 
             ls->servers = mport;
 
-            if (i == last - 1) {
-                mport->naddrs = last;
-
-            } else {
-                mport->naddrs = 1;
-                i = 0;
-            }
+            mport->naddrs = i + 1;
 
             switch (ls->sockaddr->sa_family) {
 #if (NGX_HAVE_INET6)
index e5ffcf9bc970a97f9f878609cc9c1698f856690e..18aea28af81228514a96ed9dbad78cbf8ac40907 100644 (file)
@@ -393,13 +393,7 @@ ngx_stream_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports)
 
             ls->servers = stport;
 
-            if (i == last - 1) {
-                stport->naddrs = last;
-
-            } else {
-                stport->naddrs = 1;
-                i = 0;
-            }
+            stport->naddrs = i + 1;
 
             switch (ls->sockaddr->sa_family) {
 #if (NGX_HAVE_INET6)