summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conn_accept.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-06-20 19:49:17 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-06-20 19:49:17 +0300
commitf888a5310c1808902b4035ca3454b62bc5cf4434 (patch)
tree7425e11cdba27420d21468b0f79787834bd3c498 /src/nxt_conn_accept.c
parentc7ab908c19242a5ddd0233e123e8c2be210b3c02 (diff)
downloadunit-f888a5310c1808902b4035ca3454b62bc5cf4434.tar.gz
unit-f888a5310c1808902b4035ca3454b62bc5cf4434.tar.bz2
Using new memory pool implementation.
Diffstat (limited to 'src/nxt_conn_accept.c')
-rw-r--r--src/nxt_conn_accept.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nxt_conn_accept.c b/src/nxt_conn_accept.c
index eb0172f4..4fcd530d 100644
--- a/src/nxt_conn_accept.c
+++ b/src/nxt_conn_accept.c
@@ -82,9 +82,9 @@ nxt_listen_event(nxt_task_t *task, nxt_listen_socket_t *ls)
static nxt_conn_t *
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_mem_pool_t *mp;
nxt_event_engine_t *engine;
nxt_listen_socket_t *ls;
@@ -92,11 +92,13 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
if (engine->connections < engine->max_connections) {
- mp = nxt_mem_pool_create(lev->listen->mem_pool_size);
+ mp = nxt_mp_create(1024, 128, 256, 32);
if (nxt_fast_path(mp != NULL)) {
- /* This allocation cannot fail. */
c = nxt_conn_create(mp, lev->socket.task);
+ if (nxt_slow_path(c == NULL)) {
+ goto fail;
+ }
lev->next = c;
c->socket.read_work_queue = lev->socket.read_work_queue;
@@ -104,8 +106,12 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
c->listen = lev;
ls = lev->listen;
- /* This allocation cannot fail. */
+
remote = nxt_sockaddr_alloc(mp, ls->socklen, ls->address_length);
+ if (nxt_slow_path(remote == NULL)) {
+ goto fail;
+ }
+
c->remote = remote;
sa = ls->sockaddr;
@@ -118,6 +124,10 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
return c;
}
+
+ fail:
+
+ nxt_mp_destroy(mp);
}
return NULL;