diff options
author | Max Romanov <max.romanov@nginx.com> | 2019-09-18 22:45:30 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2019-09-18 22:45:30 +0300 |
commit | 1fac43eebe4136a2f57c56f23fc90a33783e63f2 (patch) | |
tree | c335f51b7c55a8d0db1eb12d1654fb5e997678a5 /src | |
parent | ab40ce3757e6f9d50c9c1a8aa4ea01cb5278eafa (diff) | |
download | unit-1fac43eebe4136a2f57c56f23fc90a33783e63f2.tar.gz unit-1fac43eebe4136a2f57c56f23fc90a33783e63f2.tar.bz2 |
Fixing master process crash after failed fork.
This closes #312 issue on GitHub.
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_main_process.c | 9 | ||||
-rw-r--r-- | src/nxt_port.c | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 40682eb9..83c6d188 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -690,15 +690,18 @@ nxt_main_create_worker_process(nxt_task_t *task, nxt_runtime_t *rt, pid = nxt_process_create(task, process); - nxt_port_use(task, port, -1); - switch (pid) { case -1: + nxt_port_close(task, port); + nxt_port_use(task, port, -1); + return NXT_ERROR; case 0: /* A worker process, return to the event engine work queue loop. */ + nxt_port_use(task, port, -1); + return NXT_AGAIN; default: @@ -707,6 +710,8 @@ nxt_main_create_worker_process(nxt_task_t *task, nxt_runtime_t *rt, nxt_port_read_close(port); nxt_port_write_enable(task, port); + nxt_port_use(task, port, -1); + return NXT_OK; } } diff --git a/src/nxt_port.c b/src/nxt_port.c index cef65cab..9029353a 100644 --- a/src/nxt_port.c +++ b/src/nxt_port.c @@ -546,7 +546,7 @@ nxt_port_use(nxt_task_t *task, nxt_port_t *port, int i) if (i < 0 && c == -i) { - if (task->thread->engine == port->engine) { + if (port->engine == NULL || task->thread->engine == port->engine) { nxt_port_release(task, port); return; |