Closing app outgoing shared memory file descriptor.

This fixes file descriptor leakage in router.  Shared memory file used to
send data from router to application.  These files are shared among all
processes of same application and router keeps the opened file descriptor since
06017e6e3a5f commit.
This commit is contained in:
Max Romanov
2021-03-02 19:33:37 +03:00
parent 73ac0496fe
commit 1950d0aee2
2 changed files with 11 additions and 0 deletions

View File

@@ -9,6 +9,12 @@
date="" time="" date="" time=""
packager="Andrei Belov <defan@nginx.com>"> packager="Andrei Belov <defan@nginx.com>">
<change type="bugfix">
<para>
a descriptor leak occurring in the router process when removing or
reconfiguring an application; the bug had appeared in 1.19.0.
</para>
</change>
</changes> </changes>

View File

@@ -34,6 +34,10 @@ nxt_port_mmap_handler_use(nxt_port_mmap_handler_t *mmap_handler, int i)
mmap_handler->hdr = NULL; mmap_handler->hdr = NULL;
} }
if (mmap_handler->fd != -1) {
nxt_fd_close(mmap_handler->fd);
}
nxt_free(mmap_handler); nxt_free(mmap_handler);
} }
} }
@@ -238,6 +242,7 @@ nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
} }
mmap_handler->hdr = hdr; mmap_handler->hdr = hdr;
mmap_handler->fd = -1;
if (nxt_slow_path(hdr->src_pid != process->pid if (nxt_slow_path(hdr->src_pid != process->pid
|| hdr->dst_pid != nxt_pid)) || hdr->dst_pid != nxt_pid))