Fixing alerts on router restart.

Splitting the process type connectivity matrix to 'keep ports' and 'send
ports'; the 'keep ports' matrix is used to clean up unnecessary ports after
forking a new process, and the 'send ports' matrix determines which process
types expect to get created process ports.

Unfortunately, the original single connectivity matrix no longer works because
of an application stop delay caused by prototypes.  Existing applications
should not get the new router port at the moment.
This commit is contained in:
Max Romanov
2021-11-24 13:11:48 +03:00
parent 62d173f7af
commit c33c2925d9
3 changed files with 16 additions and 7 deletions

View File

@@ -216,7 +216,7 @@ nxt_port_send_new_port(nxt_task_t *task, nxt_runtime_t *rt,
port = nxt_process_port_first(process); port = nxt_process_port_first(process);
if (nxt_proc_conn_matrix[port->type][new_port->type]) { if (nxt_proc_send_matrix[port->type][new_port->type]) {
(void) nxt_port_send_port(task, port, new_port, stream); (void) nxt_port_send_port(task, port, new_port, stream);
} }

View File

@@ -58,7 +58,7 @@ nxt_uid_t nxt_euid;
/* A cached process effective gid */ /* A cached process effective gid */
nxt_gid_t nxt_egid; nxt_gid_t nxt_egid;
nxt_bool_t nxt_proc_conn_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = { uint8_t nxt_proc_keep_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = {
{ 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 },
{ 1, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 1, 0, 0 }, { 1, 0, 0, 1, 0, 0 },
@@ -67,7 +67,16 @@ nxt_bool_t nxt_proc_conn_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = {
{ 1, 0, 0, 1, 0, 0 }, { 1, 0, 0, 1, 0, 0 },
}; };
nxt_bool_t nxt_proc_remove_notify_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = { uint8_t nxt_proc_send_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = {
{ 1, 1, 1, 1, 1, 1 },
{ 1, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 1, 0, 0 },
{ 1, 0, 1, 1, 1, 1 },
{ 1, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 0, 0 },
};
uint8_t nxt_proc_remove_notify_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = {
{ 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 0 }, { 0, 0, 0, 1, 0, 0 },
@@ -265,7 +274,7 @@ nxt_process_child_fixup(nxt_task_t *task, nxt_process_t *process)
/* Remove not ready processes. */ /* Remove not ready processes. */
nxt_runtime_process_each(rt, p) { nxt_runtime_process_each(rt, p) {
if (nxt_proc_conn_matrix[ptype][nxt_process_type(p)] == 0 if (nxt_proc_keep_matrix[ptype][nxt_process_type(p)] == 0
&& p->pid != nxt_ppid) /* Always keep parent's port. */ && p->pid != nxt_ppid) /* Always keep parent's port. */
{ {
nxt_debug(task, "remove not required process %PI", p->pid); nxt_debug(task, "remove not required process %PI", p->pid);

View File

@@ -151,9 +151,9 @@ typedef struct {
} nxt_process_init_t; } nxt_process_init_t;
extern nxt_bool_t nxt_proc_conn_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX]; extern uint8_t nxt_proc_keep_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX];
extern nxt_bool_t extern uint8_t nxt_proc_send_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX];
nxt_proc_remove_notify_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX]; extern uint8_t nxt_proc_remove_notify_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX];
NXT_EXPORT nxt_pid_t nxt_process_execute(nxt_task_t *task, char *name, NXT_EXPORT nxt_pid_t nxt_process_execute(nxt_task_t *task, char *name,
char **argv, char **envp); char **argv, char **envp);