summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_socket.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-05-28 12:40:49 +0300
committerMax Romanov <max.romanov@nginx.com>2020-05-28 12:40:49 +0300
commit89b1e88f8f0b1d66a19ac9657c9568ef5fb0ff27 (patch)
treef69a9b93d4d62ac4c974d5c1a744293acbe225ca /src/nxt_port_socket.c
parentfa4d4b61200b6f465edbe24ebcdce1a7a8675d39 (diff)
downloadunit-89b1e88f8f0b1d66a19ac9657c9568ef5fb0ff27.tar.gz
unit-89b1e88f8f0b1d66a19ac9657c9568ef5fb0ff27.tar.bz2
Closing unsent file descriptors from port queue.
After a process exits, all ports linked to it from other processes should be closed. All unsent file descriptors in port queue, marked as "close after send", should be closed to avoid resource leakage.
Diffstat (limited to 'src/nxt_port_socket.c')
-rw-r--r--src/nxt_port_socket.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nxt_port_socket.c b/src/nxt_port_socket.c
index 9c7da970..4e3eaef6 100644
--- a/src/nxt_port_socket.c
+++ b/src/nxt_port_socket.c
@@ -993,6 +993,12 @@ nxt_port_error_handler(nxt_task_t *task, void *obj, void *data)
nxt_queue_each(msg, &port->messages, nxt_port_send_msg_t, link) {
+ if (msg->fd != -1 && msg->close_fd != 0) {
+ nxt_fd_close(msg->fd);
+
+ msg->fd = -1;
+ }
+
for (b = msg->buf; b != NULL; b = next) {
next = b->next;
b->next = NULL;