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_process.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_process.c')
-rw-r--r-- | src/nxt_process.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/nxt_process.c b/src/nxt_process.c index d3ec36ed..272837b6 100644 --- a/src/nxt_process.c +++ b/src/nxt_process.c @@ -58,7 +58,7 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process) if (!p->ready) { nxt_debug(task, "remove not ready process %PI", p->pid); - nxt_runtime_process_remove(task, p); + nxt_process_close_ports(task, p); } else { nxt_port_mmaps_destroy(p->incoming, 0); @@ -586,29 +586,30 @@ nxt_user_cred_set(nxt_task_t *task, nxt_user_cred_t *uc) } -static void -nxt_process_port_mp_cleanup(nxt_task_t *task, void *obj, void *data) +void +nxt_process_port_add(nxt_task_t *task, nxt_process_t *process, nxt_port_t *port) { - nxt_process_t *process; - - process = obj; + nxt_assert(port->process == NULL); - process->port_cleanups--; + port->process = process; + nxt_queue_insert_tail(&process->ports, &port->link); - if (process->port_cleanups == 0) { - nxt_runtime_process_remove(task, process); - } + nxt_process_use(task, process, 1); } + void -nxt_process_port_add(nxt_task_t *task, nxt_process_t *process, nxt_port_t *port) +nxt_process_close_ports(nxt_task_t *task, nxt_process_t *process) { - port->process = process; - nxt_queue_insert_tail(&process->ports, &port->link); + nxt_port_t *port; + + nxt_process_port_each(process, port) { - nxt_mp_cleanup(port->mem_pool, nxt_process_port_mp_cleanup, task, process, - NULL); - process->port_cleanups++; + nxt_port_close(task, port); + + nxt_runtime_port_remove(task, port); + + } nxt_process_port_loop; } @@ -622,6 +623,7 @@ nxt_process_connected_port_add(nxt_process_t *process, nxt_port_t *port) nxt_thread_mutex_unlock(&process->cp_mutex); } + void nxt_process_connected_port_remove(nxt_process_t *process, nxt_port_t *port) { @@ -632,6 +634,7 @@ nxt_process_connected_port_remove(nxt_process_t *process, nxt_port_t *port) nxt_thread_mutex_unlock(&process->cp_mutex); } + nxt_port_t * nxt_process_connected_port_find(nxt_process_t *process, nxt_pid_t pid, nxt_port_id_t port_id) |