From 9b76505bf7fe7954ebd66e23fc29dab2e6b02e47 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Mon, 25 Jan 2021 13:13:17 +0300 Subject: [PATCH] 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. --- src/nxt_router.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nxt_router.c b/src/nxt_router.c index 0416dea0..8d6e493d 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -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; }