diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-10-17 16:22:38 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-10-17 16:22:38 +0300 |
commit | 09ef66d39c277ed709e2333f992b1d87304bf663 (patch) | |
tree | 980e60508cb4c86b2a6637616001d10eaeb8f393 /src/nxt_sockaddr.c | |
parent | 1c6d4d8cff1f9c2da56ce6cc433c17b2d69fca2b (diff) | |
download | unit-09ef66d39c277ed709e2333f992b1d87304bf663.tar.gz unit-09ef66d39c277ed709e2333f992b1d87304bf663.tar.bz2 |
Storing memory cache slot hint inside nxt_sockaddr_t.
Diffstat (limited to 'src/nxt_sockaddr.c')
-rw-r--r-- | src/nxt_sockaddr.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/nxt_sockaddr.c b/src/nxt_sockaddr.c index 38e2189e..af2b8674 100644 --- a/src/nxt_sockaddr.c +++ b/src/nxt_sockaddr.c @@ -21,23 +21,22 @@ static nxt_int_t nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs); nxt_sockaddr_t * -nxt_sockaddr_cache_alloc(nxt_event_engine_t *engine, nxt_listen_event_t *lev) +nxt_sockaddr_cache_alloc(nxt_event_engine_t *engine, nxt_listen_socket_t *ls) { - size_t size; - nxt_sockaddr_t *sa; - nxt_listen_socket_t *ls; - - ls = lev->listen; + uint8_t hint; + size_t size; + nxt_sockaddr_t *sa; + hint = (uint8_t) -1; size = offsetof(nxt_sockaddr_t, u) + ls->socklen + ls->address_length; - sa = nxt_event_engine_mem_alloc(engine, &lev->mem_cache, size); + sa = nxt_event_engine_mem_alloc(engine, &hint, size); if (nxt_fast_path(sa != NULL)) { /* Zero only beginning of structure up to sockaddr_un.sun_path[1]. */ nxt_memzero(sa, offsetof(nxt_sockaddr_t, u.sockaddr.sa_data[1])); - sa->sockaddr_size = size; + sa->cache_hint = hint; sa->socklen = ls->socklen; sa->length = ls->address_length; @@ -57,7 +56,7 @@ nxt_sockaddr_cache_alloc(nxt_event_engine_t *engine, nxt_listen_event_t *lev) void nxt_sockaddr_cache_free(nxt_event_engine_t *engine, nxt_conn_t *c) { - nxt_event_engine_mem_free(engine, &c->listen->mem_cache, c->remote); + nxt_event_engine_mem_free(engine, &c->remote->cache_hint, c->remote); } @@ -82,7 +81,6 @@ nxt_sockaddr_alloc(nxt_mp_t *mp, socklen_t socklen, size_t address_length) if (nxt_fast_path(sa != NULL)) { sa->socklen = socklen; sa->length = address_length; - sa->sockaddr_size = size; } return sa; @@ -239,7 +237,7 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) sa->port_start = offset; start = nxt_pointer_to(sa, offset); - end = nxt_pointer_to(sa, sa->sockaddr_size); + end = start + sa->length; switch (sa->u.sockaddr.sa_family) { |