diff options
author | Ruslan Ermilov <ru@nginx.com> | 2016-05-20 19:10:42 +0300 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2016-05-20 19:10:42 +0300 |
commit | 48a16463fa41e508810a6914a126cfce87273cc8 (patch) | |
tree | 44b7361ba69f64ad33f4dd100bf370a2b28297bd /src/http/ngx_http.c | |
parent | f7673bb50f758cb421ca3a5186c49292a85d08ae (diff) |
Use ngx_cmp_sockaddr() where appropriate.
Diffstat (limited to 'src/http/ngx_http.c')
-rw-r--r-- | src/http/ngx_http.c | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 0ceb613d6..5bf96ce41 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -1215,14 +1215,8 @@ static ngx_int_t ngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf, ngx_http_conf_port_t *port, ngx_http_listen_opt_t *lsopt) { - u_char *p; - size_t len, off; ngx_uint_t i, default_server, proxy_protocol; - struct sockaddr *sa; ngx_http_conf_addr_t *addr; -#if (NGX_HAVE_UNIX_DOMAIN) - struct sockaddr_un *saun; -#endif #if (NGX_HTTP_SSL) ngx_uint_t ssl; #endif @@ -1235,37 +1229,14 @@ ngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf, * may fill some fields in inherited sockaddr struct's */ - sa = &lsopt->u.sockaddr; - - switch (sa->sa_family) { - -#if (NGX_HAVE_INET6) - case AF_INET6: - off = offsetof(struct sockaddr_in6, sin6_addr); - len = 16; - break; -#endif - -#if (NGX_HAVE_UNIX_DOMAIN) - case AF_UNIX: - off = offsetof(struct sockaddr_un, sun_path); - len = sizeof(saun->sun_path); - break; -#endif - - default: /* AF_INET */ - off = offsetof(struct sockaddr_in, sin_addr); - len = 4; - break; - } - - p = lsopt->u.sockaddr_data + off; - addr = port->addrs.elts; for (i = 0; i < port->addrs.nelts; i++) { - if (ngx_memcmp(p, addr[i].opt.u.sockaddr_data + off, len) != 0) { + if (ngx_cmp_sockaddr(&lsopt->u.sockaddr, lsopt->socklen, + &addr[i].opt.u.sockaddr, addr[i].opt.socklen, 0) + != NGX_OK) + { continue; } |