diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-06-23 19:19:41 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-06-23 19:19:41 +0300 |
commit | ac43bfcc72b3a92abc8d935dce8306b05b8c8185 (patch) | |
tree | 7512aa8f4a1602a7da81518e31b4349ca49faecf | |
parent | e5fe254e1e741f24d53f5199cc4f187efd6a9924 (diff) | |
download | unit-ac43bfcc72b3a92abc8d935dce8306b05b8c8185.tar.gz unit-ac43bfcc72b3a92abc8d935dce8306b05b8c8185.tar.bz2 |
nxt_process_create() changed to add process to runtime before callbacks.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_master_process.c | 11 | ||||
-rw-r--r-- | src/nxt_process.c | 24 | ||||
-rw-r--r-- | src/nxt_process.h | 2 |
3 files changed, 21 insertions, 16 deletions
diff --git a/src/nxt_master_process.c b/src/nxt_master_process.c index 218aff5e..7a23baf2 100644 --- a/src/nxt_master_process.c +++ b/src/nxt_master_process.c @@ -244,7 +244,7 @@ nxt_master_create_worker_process(nxt_task_t *task, nxt_runtime_t *rt, port->engine = 0; port->type = init->type; - pid = nxt_process_create(task, init); + pid = nxt_process_create(task, process); switch (pid) { @@ -253,19 +253,10 @@ nxt_master_create_worker_process(nxt_task_t *task, nxt_runtime_t *rt, case 0: /* A worker process, return to the event engine work queue loop. */ - process->pid = nxt_pid; - port->pid = nxt_pid; - - nxt_runtime_process_add(rt, process); - return NXT_AGAIN; default: /* The master process created a new process. */ - process->pid = pid; - port->pid = pid; - - nxt_runtime_process_add(rt, process); nxt_port_read_close(port); nxt_port_write_enable(task, port); diff --git a/src/nxt_process.c b/src/nxt_process.c index b8414b93..ce16cf7f 100644 --- a/src/nxt_process.c +++ b/src/nxt_process.c @@ -20,9 +20,12 @@ nxt_pid_t nxt_ppid; nxt_pid_t -nxt_process_create(nxt_task_t *task, nxt_process_init_t *process) +nxt_process_create(nxt_task_t *task, nxt_process_t *process) { - nxt_pid_t pid; + nxt_pid_t pid; + nxt_runtime_t *rt; + + rt = task->thread->runtime; pid = fork(); @@ -30,7 +33,7 @@ nxt_process_create(nxt_task_t *task, nxt_process_init_t *process) case -1: nxt_log(task, NXT_LOG_CRIT, "fork() failed while creating \"%s\" %E", - process->name, nxt_errno); + process->init->name, nxt_errno); break; case 0: @@ -40,12 +43,23 @@ nxt_process_create(nxt_task_t *task, nxt_process_init_t *process) /* Clean inherited cached thread tid. */ task->thread->tid = 0; - nxt_process_start(task, process); + process->pid = nxt_pid; + process->init->port->pid = nxt_pid; + + nxt_runtime_process_add(rt, process); + + nxt_process_start(task, process->init); break; default: /* A parent. */ - nxt_debug(task, "fork(\"%s\"): %PI", process->name, pid); + nxt_debug(task, "fork(\"%s\"): %PI", process->init->name, pid); + + process->pid = pid; + process->init->port->pid = pid; + + nxt_runtime_process_add(rt, process); + break; } diff --git a/src/nxt_process.h b/src/nxt_process.h index 00be35cb..669c8f03 100644 --- a/src/nxt_process.h +++ b/src/nxt_process.h @@ -62,7 +62,7 @@ typedef struct { NXT_EXPORT nxt_pid_t nxt_process_create(nxt_task_t *task, - nxt_process_init_t *process); + nxt_process_t *process); NXT_EXPORT nxt_pid_t nxt_process_execute(nxt_task_t *task, char *name, char **argv, char **envp); NXT_EXPORT nxt_int_t nxt_process_daemon(nxt_task_t *task); |