Fixed nxt_conn_accept_alloc() behavior in low memory conditions.
Earlier, if nxt_mp_create() failed to allocate memory while accepting a new connection, the resulting NULL was subsequently passed to nxt_mp_destroy(), crashing the process. More, if nxt_mp_create() was successful but nxt_sockaddr_cache_alloc() failed, the connection object wasn't destroyed properly, leaving the connection counter in an inconsistent state. Repeated, this condition lowered the connection capacity of the process and could eventually prevent it from accepting connections altogether.
This commit is contained in:
@@ -98,7 +98,9 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
|
|||||||
if (nxt_fast_path(mp != NULL)) {
|
if (nxt_fast_path(mp != NULL)) {
|
||||||
c = nxt_conn_create(mp, lev->socket.task);
|
c = nxt_conn_create(mp, lev->socket.task);
|
||||||
if (nxt_slow_path(c == NULL)) {
|
if (nxt_slow_path(c == NULL)) {
|
||||||
goto fail;
|
nxt_mp_destroy(mp);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->socket.read_work_queue = lev->socket.read_work_queue;
|
c->socket.read_work_queue = lev->socket.read_work_queue;
|
||||||
@@ -109,11 +111,9 @@ nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
|
|||||||
lev->next = c;
|
lev->next = c;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nxt_conn_free(task, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
|
||||||
|
|
||||||
nxt_mp_destroy(mp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user