Welcome! Log In Create A New Profile

Advanced

[nginx] Renamed "u" to "sockaddr" in listen options types.

Ruslan Ermilov
May 23, 2016 09:40AM
details: http://hg.nginx.org/nginx/rev/c90cf79d0e1d
branches:
changeset: 6560:c90cf79d0e1d
user: Maxim Dounin <mdounin@mdounin.ru>
date: Mon May 23 16:37:28 2016 +0300
description:
Renamed "u" to "sockaddr" in listen options types.

diffstat:

src/http/ngx_http.c | 148 ++++++++++++++++++-----------------
src/http/ngx_http_core_module.c | 12 +-
src/http/ngx_http_core_module.h | 2 +-
src/mail/ngx_mail.c | 20 ++--
src/mail/ngx_mail.h | 2 +-
src/mail/ngx_mail_core_module.c | 8 +-
src/stream/ngx_stream.c | 20 ++--
src/stream/ngx_stream.h | 2 +-
src/stream/ngx_stream_core_module.c | 10 +-
9 files changed, 113 insertions(+), 111 deletions(-)

diffs (525 lines):

diff -r adf25b8d0431 -r c90cf79d0e1d src/http/ngx_http.c
--- a/src/http/ngx_http.c Mon May 23 16:37:20 2016 +0300
+++ b/src/http/ngx_http.c Mon May 23 16:37:28 2016 +0300
@@ -1161,13 +1161,13 @@ ngx_http_add_listen(ngx_conf_t *cf, ngx_
}
}

- sa = &lsopt->u.sockaddr;
+ sa = &lsopt->sockaddr.sockaddr;

switch (sa->sa_family) {

#if (NGX_HAVE_INET6)
case AF_INET6:
- sin6 = &lsopt->u.sockaddr_in6;
+ sin6 = &lsopt->sockaddr.sockaddr_in6;
p = sin6->sin6_port;
break;
#endif
@@ -1179,7 +1179,7 @@ ngx_http_add_listen(ngx_conf_t *cf, ngx_
#endif

default: /* AF_INET */
- sin = &lsopt->u.sockaddr_in;
+ sin = &lsopt->sockaddr.sockaddr_in;
p = sin->sin_port;
break;
}
@@ -1233,8 +1233,9 @@ ngx_http_add_addresses(ngx_conf_t *cf, n

for (i = 0; i < port->addrs.nelts; i++) {

- if (ngx_cmp_sockaddr(&lsopt->u.sockaddr, lsopt->socklen,
- &addr[i].opt.u.sockaddr, addr[i].opt.socklen, 0)
+ if (ngx_cmp_sockaddr(&lsopt->sockaddr.sockaddr, lsopt->socklen,
+ &addr[i].opt.sockaddr.sockaddr,
+ addr[i].opt.socklen, 0)
!= NGX_OK)
{
continue;
@@ -1727,7 +1728,8 @@ ngx_http_add_listening(ngx_conf_t *cf, n
ngx_http_core_loc_conf_t *clcf;
ngx_http_core_srv_conf_t *cscf;

- ls = ngx_create_listening(cf, &addr->opt.u.sockaddr, addr->opt.socklen);
+ ls = ngx_create_listening(cf, &addr->opt.sockaddr.sockaddr,
+ addr->opt.socklen);
if (ls == NULL) {
return NULL;
}
@@ -1817,7 +1819,7 @@ ngx_http_add_addrs(ngx_conf_t *cf, ngx_h

for (i = 0; i < hport->naddrs; i++) {

- sin = &addr[i].opt.u.sockaddr_in;
+ sin = &addr[i].opt.sockaddr.sockaddr_in;
addrs[i].addr = sin->sin_addr.s_addr;
addrs[i].conf.default_server = addr[i].default_server;
#if (NGX_HTTP_SSL)
@@ -1846,72 +1848,7 @@ ngx_http_add_addrs(ngx_conf_t *cf, ngx_h
return NGX_ERROR;
}

- addrs[i].conf.virtual_names = vn;
-
- vn->names.hash = addr[i].hash;
- vn->names.wc_head = addr[i].wc_head;
- vn->names.wc_tail = addr[i].wc_tail;
-#if (NGX_PCRE)
- vn->nregex = addr[i].nregex;
- vn->regex = addr[i].regex;
-#endif
- }
-
- return NGX_OK;
-}
-
-
-#if (NGX_HAVE_INET6)
-
-static ngx_int_t
-ngx_http_add_addrs6(ngx_conf_t *cf, ngx_http_port_t *hport,
- ngx_http_conf_addr_t *addr)
-{
- ngx_uint_t i;
- ngx_http_in6_addr_t *addrs6;
- struct sockaddr_in6 *sin6;
- ngx_http_virtual_names_t *vn;
-
- hport->addrs = ngx_pcalloc(cf->pool,
- hport->naddrs * sizeof(ngx_http_in6_addr_t));
- if (hport->addrs == NULL) {
- return NGX_ERROR;
- }
-
- addrs6 = hport->addrs;
-
- for (i = 0; i < hport->naddrs; i++) {
-
- sin6 = &addr[i].opt.u.sockaddr_in6;
- addrs6[i].addr6 = sin6->sin6_addr;
- addrs6[i].conf.default_server = addr[i].default_server;
-#if (NGX_HTTP_SSL)
- addrs6[i].conf.ssl = addr[i].opt.ssl;
-#endif
-#if (NGX_HTTP_V2)
- addrs6[i].conf.http2 = addr[i].opt.http2;
-#endif
- addrs6[i].conf.proxy_protocol = addr[i].opt.proxy_protocol;
-
- if (addr[i].hash.buckets == NULL
- && (addr[i].wc_head == NULL
- || addr[i].wc_head->hash.buckets == NULL)
- && (addr[i].wc_tail == NULL
- || addr[i].wc_tail->hash.buckets == NULL)
-#if (NGX_PCRE)
- && addr[i].nregex == 0
-#endif
- )
- {
- continue;
- }
-
- vn = ngx_palloc(cf->pool, sizeof(ngx_http_virtual_names_t));
- if (vn == NULL) {
- return NGX_ERROR;
- }
-
- addrs6[i].conf.virtual_names = vn;
+ addrs[i].conf.virtual_names = vn;

vn->names.hash = addr[i].hash;
vn->names.wc_head = addr[i].wc_head;
@@ -1925,6 +1862,71 @@ ngx_http_add_addrs6(ngx_conf_t *cf, ngx_
return NGX_OK;
}

+
+#if (NGX_HAVE_INET6)
+
+static ngx_int_t
+ngx_http_add_addrs6(ngx_conf_t *cf, ngx_http_port_t *hport,
+ ngx_http_conf_addr_t *addr)
+{
+ ngx_uint_t i;
+ ngx_http_in6_addr_t *addrs6;
+ struct sockaddr_in6 *sin6;
+ ngx_http_virtual_names_t *vn;
+
+ hport->addrs = ngx_pcalloc(cf->pool,
+ hport->naddrs * sizeof(ngx_http_in6_addr_t));
+ if (hport->addrs == NULL) {
+ return NGX_ERROR;
+ }
+
+ addrs6 = hport->addrs;
+
+ for (i = 0; i < hport->naddrs; i++) {
+
+ sin6 = &addr[i].opt.sockaddr.sockaddr_in6;
+ addrs6[i].addr6 = sin6->sin6_addr;
+ addrs6[i].conf.default_server = addr[i].default_server;
+#if (NGX_HTTP_SSL)
+ addrs6[i].conf.ssl = addr[i].opt.ssl;
+#endif
+#if (NGX_HTTP_V2)
+ addrs6[i].conf.http2 = addr[i].opt.http2;
+#endif
+ addrs6[i].conf.proxy_protocol = addr[i].opt.proxy_protocol;
+
+ if (addr[i].hash.buckets == NULL
+ && (addr[i].wc_head == NULL
+ || addr[i].wc_head->hash.buckets == NULL)
+ && (addr[i].wc_tail == NULL
+ || addr[i].wc_tail->hash.buckets == NULL)
+#if (NGX_PCRE)
+ && addr[i].nregex == 0
+#endif
+ )
+ {
+ continue;
+ }
+
+ vn = ngx_palloc(cf->pool, sizeof(ngx_http_virtual_names_t));
+ if (vn == NULL) {
+ return NGX_ERROR;
+ }
+
+ addrs6[i].conf.virtual_names = vn;
+
+ vn->names.hash = addr[i].hash;
+ vn->names.wc_head = addr[i].wc_head;
+ vn->names.wc_tail = addr[i].wc_tail;
+#if (NGX_PCRE)
+ vn->nregex = addr[i].nregex;
+ vn->regex = addr[i].regex;
+#endif
+ }
+
+ return NGX_OK;
+}
+
#endif


diff -r adf25b8d0431 -r c90cf79d0e1d src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c Mon May 23 16:37:20 2016 +0300
+++ b/src/http/ngx_http_core_module.c Mon May 23 16:37:28 2016 +0300
@@ -3030,7 +3030,7 @@ ngx_http_core_server(ngx_conf_t *cf, ngx
if (rv == NGX_CONF_OK && !cscf->listen) {
ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t));

- sin = &lsopt.u.sockaddr_in;
+ sin = &lsopt.sockaddr.sockaddr_in;

sin->sin_family = AF_INET;
#if (NGX_WIN32)
@@ -3053,8 +3053,8 @@ ngx_http_core_server(ngx_conf_t *cf, ngx
#endif
lsopt.wildcard = 1;

- (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.socklen, lsopt.addr,
- NGX_SOCKADDR_STRLEN, 1);
+ (void) ngx_sock_ntop(&lsopt.sockaddr.sockaddr, lsopt.socklen,
+ lsopt.addr, NGX_SOCKADDR_STRLEN, 1);

if (ngx_http_add_listen(cf, cscf, &lsopt) != NGX_OK) {
return NGX_CONF_ERROR;
@@ -3998,7 +3998,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx

ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t));

- ngx_memcpy(&lsopt.u.sockaddr, &u.sockaddr, u.socklen);
+ ngx_memcpy(&lsopt.sockaddr.sockaddr, &u.sockaddr, u.socklen);

lsopt.socklen = u.socklen;
lsopt.backlog = NGX_LISTEN_BACKLOG;
@@ -4015,7 +4015,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx
lsopt.ipv6only = 1;
#endif

- (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.socklen, lsopt.addr,
+ (void) ngx_sock_ntop(&lsopt.sockaddr.sockaddr, lsopt.socklen, lsopt.addr,
NGX_SOCKADDR_STRLEN, 1);

for (n = 2; n < cf->args->nelts; n++) {
@@ -4144,7 +4144,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
struct sockaddr *sa;

- sa = &lsopt.u.sockaddr;
+ sa = &lsopt.sockaddr.sockaddr;

if (sa->sa_family == AF_INET6) {

diff -r adf25b8d0431 -r c90cf79d0e1d src/http/ngx_http_core_module.h
--- a/src/http/ngx_http_core_module.h Mon May 23 16:37:20 2016 +0300
+++ b/src/http/ngx_http_core_module.h Mon May 23 16:37:28 2016 +0300
@@ -58,7 +58,7 @@ typedef struct ngx_http_core_loc_conf_s


typedef struct {
- ngx_sockaddr_t u;
+ ngx_sockaddr_t sockaddr;
socklen_t socklen;

unsigned set:1;
diff -r adf25b8d0431 -r c90cf79d0e1d src/mail/ngx_mail.c
--- a/src/mail/ngx_mail.c Mon May 23 16:37:20 2016 +0300
+++ b/src/mail/ngx_mail.c Mon May 23 16:37:28 2016 +0300
@@ -235,13 +235,13 @@ ngx_mail_add_ports(ngx_conf_t *cf, ngx_a
struct sockaddr_in6 *sin6;
#endif

- sa = &listen->u.sockaddr;
+ sa = &listen->sockaddr.sockaddr;

switch (sa->sa_family) {

#if (NGX_HAVE_INET6)
case AF_INET6:
- sin6 = &listen->u.sockaddr_in6;
+ sin6 = &listen->sockaddr.sockaddr_in6;
p = sin6->sin6_port;
break;
#endif
@@ -253,7 +253,7 @@ ngx_mail_add_ports(ngx_conf_t *cf, ngx_a
#endif

default: /* AF_INET */
- sin = &listen->u.sockaddr_in;
+ sin = &listen->sockaddr.sockaddr_in;
p = sin->sin_port;
break;
}
@@ -340,7 +340,7 @@ ngx_mail_optimize_servers(ngx_conf_t *cf
continue;
}

- ls = ngx_create_listening(cf, &addr[i].opt.u.sockaddr,
+ ls = ngx_create_listening(cf, &addr[i].opt.sockaddr.sockaddr,
addr[i].opt.socklen);
if (ls == NULL) {
return NGX_CONF_ERROR;
@@ -423,7 +423,7 @@ ngx_mail_add_addrs(ngx_conf_t *cf, ngx_m

for (i = 0; i < mport->naddrs; i++) {

- sin = &addr[i].opt.u.sockaddr_in;
+ sin = &addr[i].opt.sockaddr.sockaddr_in;
addrs[i].addr = sin->sin_addr.s_addr;

addrs[i].conf.ctx = addr[i].opt.ctx;
@@ -431,8 +431,8 @@ ngx_mail_add_addrs(ngx_conf_t *cf, ngx_m
addrs[i].conf.ssl = addr[i].opt.ssl;
#endif

- len = ngx_sock_ntop(&addr[i].opt.u.sockaddr, addr[i].opt.socklen, buf,
- NGX_SOCKADDR_STRLEN, 1);
+ len = ngx_sock_ntop(&addr[i].opt.sockaddr.sockaddr, addr[i].opt.socklen,
+ buf, NGX_SOCKADDR_STRLEN, 1);

p = ngx_pnalloc(cf->pool, len);
if (p == NULL) {
@@ -472,7 +472,7 @@ ngx_mail_add_addrs6(ngx_conf_t *cf, ngx_

for (i = 0; i < mport->naddrs; i++) {

- sin6 = &addr[i].opt.u.sockaddr_in6;
+ sin6 = &addr[i].opt.sockaddr.sockaddr_in6;
addrs6[i].addr6 = sin6->sin6_addr;

addrs6[i].conf.ctx = addr[i].opt.ctx;
@@ -480,8 +480,8 @@ ngx_mail_add_addrs6(ngx_conf_t *cf, ngx_
addrs6[i].conf.ssl = addr[i].opt.ssl;
#endif

- len = ngx_sock_ntop(&addr[i].opt.u.sockaddr, addr[i].opt.socklen, buf,
- NGX_SOCKADDR_STRLEN, 1);
+ len = ngx_sock_ntop(&addr[i].opt.sockaddr.sockaddr, addr[i].opt.socklen,
+ buf, NGX_SOCKADDR_STRLEN, 1);

p = ngx_pnalloc(cf->pool, len);
if (p == NULL) {
diff -r adf25b8d0431 -r c90cf79d0e1d src/mail/ngx_mail.h
--- a/src/mail/ngx_mail.h Mon May 23 16:37:20 2016 +0300
+++ b/src/mail/ngx_mail.h Mon May 23 16:37:28 2016 +0300
@@ -27,7 +27,7 @@ typedef struct {


typedef struct {
- ngx_sockaddr_t u;
+ ngx_sockaddr_t sockaddr;
socklen_t socklen;

/* server ctx */
diff -r adf25b8d0431 -r c90cf79d0e1d src/mail/ngx_mail_core_module.c
--- a/src/mail/ngx_mail_core_module.c Mon May 23 16:37:20 2016 +0300
+++ b/src/mail/ngx_mail_core_module.c Mon May 23 16:37:28 2016 +0300
@@ -318,7 +318,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx

for (i = 0; i < cmcf->listen.nelts; i++) {

- if (ngx_cmp_sockaddr(&ls[i].u.sockaddr, ls[i].socklen,
+ if (ngx_cmp_sockaddr(&ls[i].sockaddr.sockaddr, ls[i].socklen,
(struct sockaddr *) &u.sockaddr, u.socklen, 1)
!= NGX_OK)
{
@@ -337,7 +337,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx

ngx_memzero(ls, sizeof(ngx_mail_listen_t));

- ngx_memcpy(&ls->u.sockaddr, &u.sockaddr, u.socklen);
+ ngx_memcpy(&ls->sockaddr.sockaddr, &u.sockaddr, u.socklen);

ls->socklen = u.socklen;
ls->backlog = NGX_LISTEN_BACKLOG;
@@ -394,7 +394,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx
size_t len;
u_char buf[NGX_SOCKADDR_STRLEN];

- if (ls->u.sockaddr.sa_family == AF_INET6) {
+ if (ls->sockaddr.sockaddr.sa_family == AF_INET6) {

if (ngx_strcmp(&value[i].data[10], "n") == 0) {
ls->ipv6only = 1;
@@ -412,7 +412,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx
ls->bind = 1;

} else {
- len = ngx_sock_ntop(&ls->u.sockaddr, ls->socklen, buf,
+ len = ngx_sock_ntop(&ls->sockaddr.sockaddr, ls->socklen, buf,
NGX_SOCKADDR_STRLEN, 1);

ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
diff -r adf25b8d0431 -r c90cf79d0e1d src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c Mon May 23 16:37:20 2016 +0300
+++ b/src/stream/ngx_stream.c Mon May 23 16:37:28 2016 +0300
@@ -250,13 +250,13 @@ ngx_stream_add_ports(ngx_conf_t *cf, ngx
struct sockaddr_in6 *sin6;
#endif

- sa = &listen->u.sockaddr;
+ sa = &listen->sockaddr.sockaddr;

switch (sa->sa_family) {

#if (NGX_HAVE_INET6)
case AF_INET6:
- sin6 = &listen->u.sockaddr_in6;
+ sin6 = &listen->sockaddr.sockaddr_in6;
p = sin6->sin6_port;
break;
#endif
@@ -268,7 +268,7 @@ ngx_stream_add_ports(ngx_conf_t *cf, ngx
#endif

default: /* AF_INET */
- sin = &listen->u.sockaddr_in;
+ sin = &listen->sockaddr.sockaddr_in;
p = sin->sin_port;
break;
}
@@ -359,7 +359,7 @@ ngx_stream_optimize_servers(ngx_conf_t *
continue;
}

- ls = ngx_create_listening(cf, &addr[i].opt.u.sockaddr,
+ ls = ngx_create_listening(cf, &addr[i].opt.sockaddr.sockaddr,
addr[i].opt.socklen);
if (ls == NULL) {
return NGX_CONF_ERROR;
@@ -453,7 +453,7 @@ ngx_stream_add_addrs(ngx_conf_t *cf, ngx

for (i = 0; i < stport->naddrs; i++) {

- sin = &addr[i].opt.u.sockaddr_in;
+ sin = &addr[i].opt.sockaddr.sockaddr_in;
addrs[i].addr = sin->sin_addr.s_addr;

addrs[i].conf.ctx = addr[i].opt.ctx;
@@ -461,8 +461,8 @@ ngx_stream_add_addrs(ngx_conf_t *cf, ngx
addrs[i].conf.ssl = addr[i].opt.ssl;
#endif

- len = ngx_sock_ntop(&addr[i].opt.u.sockaddr, addr[i].opt.socklen, buf,
- NGX_SOCKADDR_STRLEN, 1);
+ len = ngx_sock_ntop(&addr[i].opt.sockaddr.sockaddr, addr[i].opt.socklen,
+ buf, NGX_SOCKADDR_STRLEN, 1);

p = ngx_pnalloc(cf->pool, len);
if (p == NULL) {
@@ -502,7 +502,7 @@ ngx_stream_add_addrs6(ngx_conf_t *cf, ng

for (i = 0; i < stport->naddrs; i++) {

- sin6 = &addr[i].opt.u.sockaddr_in6;
+ sin6 = &addr[i].opt.sockaddr.sockaddr_in6;
addrs6[i].addr6 = sin6->sin6_addr;

addrs6[i].conf.ctx = addr[i].opt.ctx;
@@ -510,8 +510,8 @@ ngx_stream_add_addrs6(ngx_conf_t *cf, ng
addrs6[i].conf.ssl = addr[i].opt.ssl;
#endif

- len = ngx_sock_ntop(&addr[i].opt.u.sockaddr, addr[i].opt.socklen, buf,
- NGX_SOCKADDR_STRLEN, 1);
+ len = ngx_sock_ntop(&addr[i].opt.sockaddr.sockaddr, addr[i].opt.socklen,
+ buf, NGX_SOCKADDR_STRLEN, 1);

p = ngx_pnalloc(cf->pool, len);
if (p == NULL) {
diff -r adf25b8d0431 -r c90cf79d0e1d src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h Mon May 23 16:37:20 2016 +0300
+++ b/src/stream/ngx_stream.h Mon May 23 16:37:28 2016 +0300
@@ -31,7 +31,7 @@ typedef struct {


typedef struct {
- ngx_sockaddr_t u;
+ ngx_sockaddr_t sockaddr;
socklen_t socklen;

/* server ctx */
diff -r adf25b8d0431 -r c90cf79d0e1d src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c Mon May 23 16:37:20 2016 +0300
+++ b/src/stream/ngx_stream_core_module.c Mon May 23 16:37:28 2016 +0300
@@ -280,7 +280,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, n

ngx_memzero(ls, sizeof(ngx_stream_listen_t));

- ngx_memcpy(&ls->u.sockaddr, &u.sockaddr, u.socklen);
+ ngx_memcpy(&ls->sockaddr.sockaddr, &u.sockaddr, u.socklen);

ls->socklen = u.socklen;
ls->backlog = NGX_LISTEN_BACKLOG;
@@ -328,7 +328,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
size_t len;
u_char buf[NGX_SOCKADDR_STRLEN];

- if (ls->u.sockaddr.sa_family == AF_INET6) {
+ if (ls->sockaddr.sockaddr.sa_family == AF_INET6) {

if (ngx_strcmp(&value[i].data[10], "n") == 0) {
ls->ipv6only = 1;
@@ -346,7 +346,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
ls->bind = 1;

} else {
- len = ngx_sock_ntop(&ls->u.sockaddr, ls->socklen, buf,
+ len = ngx_sock_ntop(&ls->sockaddr.sockaddr, ls->socklen, buf,
NGX_SOCKADDR_STRLEN, 1);

ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@@ -505,8 +505,8 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
continue;
}

- if (ngx_cmp_sockaddr(&als[i].u.sockaddr, als[i].socklen,
- &ls->u.sockaddr, ls->socklen, 1)
+ if (ngx_cmp_sockaddr(&als[i].sockaddr.sockaddr, als[i].socklen,
+ &ls->sockaddr.sockaddr, ls->socklen, 1)
!= NGX_OK)
{
continue;

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

[nginx] Renamed "u" to "sockaddr" in listen options types.

Ruslan Ermilov 332 May 23, 2016 09:40AM



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

Online Users

Guests: 151
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