Welcome! Log In Create A New Profile

Advanced

[nginx] Simplified ngx_http_init_listening().

Maxim Dounin
May 20, 2015 09:02AM
details: http://hg.nginx.org/nginx/rev/3c344ea7d88b
branches:
changeset: 6152:3c344ea7d88b
user: Maxim Dounin <mdounin@mdounin.ru>
date: Wed May 20 15:51:28 2015 +0300
description:
Simplified ngx_http_init_listening().

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.

diffstat:

src/http/ngx_http.c | 8 +-------
src/mail/ngx_mail.c | 8 +-------
src/stream/ngx_stream.c | 8 +-------
3 files changed, 3 insertions(+), 21 deletions(-)

diffs (54 lines):

diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1719,13 +1719,7 @@ ngx_http_init_listening(ngx_conf_t *cf,

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) {

diff --git a/src/mail/ngx_mail.c b/src/mail/ngx_mail.c
--- a/src/mail/ngx_mail.c
+++ b/src/mail/ngx_mail.c
@@ -392,13 +392,7 @@ ngx_mail_optimize_servers(ngx_conf_t *cf

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)
diff --git a/src/stream/ngx_stream.c b/src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c
+++ b/src/stream/ngx_stream.c
@@ -393,13 +393,7 @@ ngx_stream_optimize_servers(ngx_conf_t *

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)

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Simplified ngx_http_init_listening().

Maxim Dounin 484 May 20, 2015 09:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 211
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready