summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2021-07-19 16:23:13 +0300
committerMax Romanov <max.romanov@nginx.com>2021-07-19 16:23:13 +0300
commitdaa051e7e7266325ef38a606b3aee4377a73f0d0 (patch)
tree9e2ef1360cecde2680d30ead4ef564b8001cedf2
parent4f94df6a71d60e3930d3d5f1dd1301ba43778618 (diff)
downloadunit-daa051e7e7266325ef38a606b3aee4377a73f0d0.tar.gz
unit-daa051e7e7266325ef38a606b3aee4377a73f0d0.tar.bz2
Router: fixing assertion on app thread port handle.
A new application thread port message can be processed in the router after the application is removed from the router. Assertion for this case is replaced by a condition to store the new thread port until receiving the stop notification from the application process.
-rw-r--r--docs/changes.xml7
-rw-r--r--src/nxt_router.c18
2 files changed, 17 insertions, 8 deletions
diff --git a/docs/changes.xml b/docs/changes.xml
index 5265d529..dd8fb731 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -46,6 +46,13 @@ with TLS certificate configured; the bug had appeared in 1.23.0.
<change type="bugfix">
<para>
+the router process could crash on rapid mutithreaded application
+reconfiguration.
+</para>
+</change>
+
+<change type="bugfix">
+<para>
a descriptor and memory leak occurred in the router process when an app
process stopped or crashed.
</para>
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 26b846b0..409f88a1 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -680,18 +680,20 @@ nxt_router_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
nxt_assert(main_app_port != NULL);
app = main_app_port->app;
- nxt_assert(app != NULL);
- nxt_thread_mutex_lock(&app->mutex);
+ if (nxt_fast_path(app != NULL)) {
+ nxt_thread_mutex_lock(&app->mutex);
- /* TODO here should be find-and-add code because there can be
- port waiters in port_hash */
- nxt_port_hash_add(&app->port_hash, port);
- app->port_hash_count++;
+ /* TODO here should be find-and-add code because there can be
+ port waiters in port_hash */
+ nxt_port_hash_add(&app->port_hash, port);
+ app->port_hash_count++;
- nxt_thread_mutex_unlock(&app->mutex);
+ nxt_thread_mutex_unlock(&app->mutex);
+
+ port->app = app;
+ }
- port->app = app;
port->main_app_port = main_app_port;
nxt_port_socket_write(task, port, NXT_PORT_MSG_PORT_ACK, -1, 0, 0, NULL);