diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-10-04 14:58:47 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-10-04 14:58:47 +0300 |
commit | 6a64533fa3b96bb64bfde4615e40376d65a292cb (patch) | |
tree | a18ed8059158d833290519e1135209747e28af21 /src/nxt_process.c | |
parent | 414d508e04d26ebef0e3e1ba4ed518b11d3af1a0 (diff) | |
download | unit-6a64533fa3b96bb64bfde4615e40376d65a292cb.tar.gz unit-6a64533fa3b96bb64bfde4615e40376d65a292cb.tar.bz2 |
Introducing use counters for port and app. Thread safe port write.
Use counter helps to simplify logic around port and application free.
Port 'post' function introduced to simplify post execution of particular
function to original port engine's thread.
Write message queue is protected by mutex which makes port write operation
thread safe.
Diffstat (limited to 'src/nxt_process.c')
-rw-r--r-- | src/nxt_process.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/nxt_process.c b/src/nxt_process.c index 95e701f8..d3ec36ed 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(rt, p); + nxt_runtime_process_remove(task, p); } else { nxt_port_mmaps_destroy(p->incoming, 0); @@ -67,7 +67,7 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process) } nxt_runtime_process_loop; - nxt_runtime_process_add(rt, process); + nxt_runtime_process_add(task, process); nxt_process_start(task, process); @@ -81,7 +81,7 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process) process->pid = pid; - nxt_runtime_process_add(rt, process); + nxt_runtime_process_add(task, process); break; } @@ -589,16 +589,14 @@ 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) { - nxt_runtime_t *rt; nxt_process_t *process; process = obj; - rt = data; process->port_cleanups--; if (process->port_cleanups == 0) { - nxt_runtime_process_remove(rt, process); + nxt_runtime_process_remove(task, process); } } @@ -609,7 +607,7 @@ nxt_process_port_add(nxt_task_t *task, nxt_process_t *process, nxt_port_t *port) nxt_queue_insert_tail(&process->ports, &port->link); nxt_mp_cleanup(port->mem_pool, nxt_process_port_mp_cleanup, task, process, - task->thread->runtime); + NULL); process->port_cleanups++; } |