Router: fixing assertion in shortage of file descriptors.

Each application in router process required fd for a request queue shared
memory.  When the number of file descripts close to the limit, and port sockets
successfully opened, router needs to properly handle the errors.

This patch closes port sockets before destroying port structure to avoid
file descriptors leakage and assertion in debug build.
This commit is contained in:
Max Romanov
2021-01-25 13:13:17 +03:00
parent 6e28263d65
commit 9b76505bf7

View File

@@ -1586,6 +1586,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
ret = nxt_router_app_queue_init(task, port);
if (nxt_slow_path(ret != NXT_OK)) {
nxt_port_write_close(port);
nxt_port_read_close(port);
nxt_port_use(task, port, -1);
return NXT_ERROR;
}