diff options
author | Andrei Belov <defan@nginx.com> | 2020-08-13 19:28:27 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-08-13 19:28:27 +0300 |
commit | aff76e4f90b4e948c327ce2b021dc3203c33cbcd (patch) | |
tree | 5bd6ac3aa92683777548472984c209bf26d8a971 /src/nxt_main_process.c | |
parent | 04ce9f997e0e49e57ce4b5fc4aa98134232a1974 (diff) | |
parent | 6473d4b65a99aa10d509220fb99d8c4f65631ed0 (diff) | |
download | unit-aff76e4f90b4e948c327ce2b021dc3203c33cbcd.tar.gz unit-aff76e4f90b4e948c327ce2b021dc3203c33cbcd.tar.bz2 |
Merged with the default branch.1.19.0-1
Diffstat (limited to '')
-rw-r--r-- | src/nxt_main_process.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index a16e44d3..48eb2abb 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -605,25 +605,22 @@ nxt_main_start_process(nxt_task_t *task, nxt_process_t *process) nxt_process_port_add(task, process, port); - nxt_process_use(task, process, -1); - - ret = NXT_ERROR; - tmp_mp = NULL; - ret = nxt_port_socket_init(task, port, 0); if (nxt_slow_path(ret != NXT_OK)) { - goto fail; + goto free_port; } tmp_mp = nxt_mp_create(1024, 128, 256, 32); - if (tmp_mp == NULL) { - goto fail; + if (nxt_slow_path(tmp_mp == NULL)) { + ret = NXT_ERROR; + + goto close_port; } if (init->prefork) { ret = init->prefork(task, process, tmp_mp); if (nxt_slow_path(ret != NXT_OK)) { - goto fail; + goto free_mempool; } } @@ -632,18 +629,22 @@ nxt_main_start_process(nxt_task_t *task, nxt_process_t *process) switch (pid) { case -1: - nxt_port_close(task, port); + ret = NXT_ERROR; break; case 0: /* The child process: return to the event engine work queue loop. */ + nxt_process_use(task, process, -1); + ret = NXT_AGAIN; break; default: /* The main process created a new process. */ + nxt_process_use(task, process, -1); + nxt_port_read_close(port); nxt_port_write_enable(task, port); @@ -651,14 +652,20 @@ nxt_main_start_process(nxt_task_t *task, nxt_process_t *process) break; } -fail: +free_mempool: - nxt_port_use(task, port, -1); + nxt_mp_destroy(tmp_mp); + +close_port: - if (nxt_fast_path(tmp_mp != NULL)) { - nxt_mp_destroy(tmp_mp); + if (nxt_slow_path(ret == NXT_ERROR)) { + nxt_port_close(task, port); } +free_port: + + nxt_port_use(task, port, -1); + return ret; } |