diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-09-27 19:22:59 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-09-27 19:22:59 +0300 |
commit | bfa808d68997d74bfe0d54196bbbb649646787c1 (patch) | |
tree | 16751ca3da7dfd1c3c7830b3203fffdaea55b0cf /src/nxt_conn_accept.c | |
parent | 752038eea857988045ce72252e0d1c19509981b3 (diff) | |
download | unit-bfa808d68997d74bfe0d54196bbbb649646787c1.tar.gz unit-bfa808d68997d74bfe0d54196bbbb649646787c1.tar.bz2 |
Event engine memory cache for nxt_sockaddr_t.
Introducing event engine memory cache and using the cache for
nxt_sockaddr_t structures.
Diffstat (limited to 'src/nxt_conn_accept.c')
-rw-r--r-- | src/nxt_conn_accept.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/nxt_conn_accept.c b/src/nxt_conn_accept.c index 660b41ff..38b36270 100644 --- a/src/nxt_conn_accept.c +++ b/src/nxt_conn_accept.c @@ -46,6 +46,8 @@ nxt_listen_event(nxt_task_t *task, nxt_listen_socket_t *ls) engine = task->thread->engine; lev->batch = engine->batch; + lev->mem_cache = (uint32_t) -1; + lev->socket.read_work_queue = &engine->accept_work_queue; lev->socket.read_handler = nxt_conn_listen_handler; lev->socket.error_handler = nxt_conn_listen_event_error; @@ -84,7 +86,6 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev) { nxt_mp_t *mp; nxt_conn_t *c; - nxt_sockaddr_t *sa, *remote; nxt_event_engine_t *engine; nxt_listen_socket_t *ls; @@ -107,23 +108,10 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev) ls = lev->listen; - remote = nxt_sockaddr_alloc(mp, ls->socklen, ls->address_length); - if (nxt_slow_path(remote == NULL)) { - goto fail; + c->remote = nxt_sockaddr_cache_alloc(engine, lev); + if (nxt_fast_path(c->remote != NULL)) { + return c; } - - c->remote = remote; - - sa = ls->sockaddr; - remote->type = sa->type; - /* - * Set address family for unspecified Unix domain socket, - * because these sockaddr's are not updated by old BSD systems, - * see comment in nxt_conn_io_accept(). - */ - remote->u.sockaddr.sa_family = sa->u.sockaddr.sa_family; - - return c; } fail: |