summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2018-09-20 16:16:32 +0300
committerMax Romanov <max.romanov@nginx.com>2018-09-20 16:16:32 +0300
commit9fe6e75d355266024f67a5611120c3c97557be14 (patch)
tree78a854a884b384c6d83f7d60394e342f1cf9339e
parentfea05e30653a4c660d538cc6915494d7145ad969 (diff)
downloadunit-9fe6e75d355266024f67a5611120c3c97557be14.tar.gz
unit-9fe6e75d355266024f67a5611120c3c97557be14.tar.bz2
Preventing port from release in asynchronous operations.
Router reconfiguration may lead to starting new application processes, opening listen ports etc. These actions are asynchronous and require message exchange with master process. Router stores reference for controller (response) port in structure associated with reconfiguration process (tmcf). The port used to provide reconfiguration response (either success or failed) to controller. This commit increases response port use counter to make sure port structure not freed while router waits for result of asynchronous operations.
-rw-r--r--src/nxt_router.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 21a7b4d7..139b2c4c 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -874,6 +874,14 @@ nxt_router_conf_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
msg->port_msg.pid,
msg->port_msg.reply_port);
+ if (nxt_slow_path(tmcf->port == NULL)) {
+ nxt_alert(task, "reply port not found");
+
+ return;
+ }
+
+ nxt_port_use(task, tmcf->port, 1);
+
b = nxt_buf_chk_make_plain(tmcf->router_conf->mem_pool,
msg->buf, msg->size);
if (nxt_slow_path(b == NULL)) {
@@ -1204,6 +1212,10 @@ nxt_router_conf_send(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
nxt_port_msg_type_t type)
{
nxt_port_socket_write(task, tmcf->port, type, -1, tmcf->stream, 0, NULL);
+
+ nxt_port_use(task, tmcf->port, -1);
+
+ tmcf->port = NULL;
}