summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nxt_router.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 1e58a589..155d1dff 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -3016,7 +3016,7 @@ static nxt_sockaddr_t *
nxt_router_local_addr(nxt_task_t *task, nxt_conn_t *c)
{
int ret;
- size_t size;
+ size_t size, length;
socklen_t socklen;
nxt_sockaddr_t *sa;
@@ -3030,13 +3030,15 @@ nxt_router_local_addr(nxt_task_t *task, nxt_conn_t *c)
#if (NXT_INET6)
case AF_INET6:
socklen = sizeof(struct sockaddr_in6);
- size = offsetof(nxt_sockaddr_t, u) + socklen + NXT_INET6_ADDR_STR_LEN;
+ length = NXT_INET6_ADDR_STR_LEN;
+ size = offsetof(nxt_sockaddr_t, u) + socklen + length;
break;
#endif
case AF_INET:
default:
- socklen = sizeof(struct sockaddr_in6);
- size = offsetof(nxt_sockaddr_t, u) + socklen + NXT_INET_ADDR_STR_LEN;
+ socklen = sizeof(struct sockaddr_in);
+ length = NXT_INET_ADDR_STR_LEN;
+ size = offsetof(nxt_sockaddr_t, u) + socklen + length;
break;
}
@@ -3045,6 +3047,9 @@ nxt_router_local_addr(nxt_task_t *task, nxt_conn_t *c)
return NULL;
}
+ sa->socklen = socklen;
+ sa->length = length;
+
ret = getsockname(c->socket.fd, &sa->u.sockaddr, &socklen);
if (nxt_slow_path(ret != 0)) {
nxt_log(task, NXT_LOG_CRIT, "getsockname(%d) failed", c->socket.fd);