diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-10-04 15:02:11 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-10-04 15:02:11 +0300 |
commit | e44401a0bb72aa66bec0322fa05e8c86fefc9074 (patch) | |
tree | f5a7013e7d811f13515ed7bfc9dc96ff7c6729d6 /src/nxt_port.c | |
parent | f869bf1b020ed41d5a64b106ba48ec45412b912c (diff) | |
download | unit-e44401a0bb72aa66bec0322fa05e8c86fefc9074.tar.gz unit-e44401a0bb72aa66bec0322fa05e8c86fefc9074.tar.bz2 |
Introducing process use counter.
This helps to decouple process removal from port memory pool cleanups.
Diffstat (limited to 'src/nxt_port.c')
-rw-r--r-- | src/nxt_port.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nxt_port.c b/src/nxt_port.c index 948e4de6..df652ac4 100644 --- a/src/nxt_port.c +++ b/src/nxt_port.c @@ -112,7 +112,11 @@ nxt_port_release(nxt_task_t *task, nxt_port_t *port) } if (port->link.next != NULL) { + nxt_assert(port->process != NULL); + nxt_process_port_remove(port); + + nxt_process_use(task, port->process, -1); } nxt_mp_release(port->mem_pool, NULL); @@ -265,11 +269,14 @@ nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) port = nxt_port_new(task, new_port_msg->id, new_port_msg->pid, new_port_msg->type); if (nxt_slow_path(port == NULL)) { + nxt_process_use(task, process, -1); return; } nxt_process_port_add(task, process, port); + nxt_process_use(task, process, -1); + port->pair[0] = -1; port->pair[1] = msg->fd; port->max_size = new_port_msg->max_size; @@ -298,7 +305,7 @@ nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) nxt_assert(nxt_runtime_is_main(rt)); - process = nxt_runtime_process_get(rt, msg->port_msg.pid); + process = nxt_runtime_process_find(rt, msg->port_msg.pid); if (nxt_slow_path(process == NULL)) { return; } @@ -452,7 +459,7 @@ nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) process = nxt_runtime_process_find(rt, pid); if (process) { - nxt_runtime_process_remove(task, process); + nxt_process_close_ports(task, process); } } |