diff options
author | Ruslan Ermilov <ru@nginx.com> | 2016-05-23 16:37:20 +0300 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2016-05-23 16:37:20 +0300 |
commit | fd064d3b88e59ee71aec508687403539b01d643c (patch) | |
tree | 8cec8e57171f8484d0e720b51b331e716d843a1d /src/core/ngx_connection.c | |
parent | d650688ba5f966bd13b5449b52192b19a4715ee4 (diff) |
Introduced the ngx_sockaddr_t type.
It's properly aligned and can hold any supported sockaddr.
Diffstat (limited to 'src/core/ngx_connection.c')
-rw-r--r-- | src/core/ngx_connection.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 19ec4ab75..16ba63003 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -151,12 +151,12 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle) ls = cycle->listening.elts; for (i = 0; i < cycle->listening.nelts; i++) { - ls[i].sockaddr = ngx_palloc(cycle->pool, NGX_SOCKADDRLEN); + ls[i].sockaddr = ngx_palloc(cycle->pool, sizeof(ngx_sockaddr_t)); if (ls[i].sockaddr == NULL) { return NGX_ERROR; } - ls[i].socklen = NGX_SOCKADDRLEN; + ls[i].socklen = sizeof(ngx_sockaddr_t); if (getsockname(ls[i].fd, ls[i].sockaddr, &ls[i].socklen) == -1) { ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno, "getsockname() of the inherited " @@ -1278,7 +1278,7 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s, { socklen_t len; ngx_uint_t addr; - u_char sa[NGX_SOCKADDRLEN]; + ngx_sockaddr_t sa; struct sockaddr_in *sin; #if (NGX_HAVE_INET6) ngx_uint_t i; @@ -1316,9 +1316,9 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s, if (addr == 0) { - len = NGX_SOCKADDRLEN; + len = sizeof(ngx_sockaddr_t); - if (getsockname(c->fd, (struct sockaddr *) &sa, &len) == -1) { + if (getsockname(c->fd, &sa.sockaddr, &len) == -1) { ngx_connection_error(c, ngx_socket_errno, "getsockname() failed"); return NGX_ERROR; } |