Preserving the app port write socket.
The socket is required for intercontextual communication in multithreaded apps.
This commit is contained in:
@@ -723,7 +723,7 @@ nxt_unit_default_init(nxt_task_t *task, nxt_unit_init_t *init)
|
|||||||
init->read_port.id.pid = my_port->pid;
|
init->read_port.id.pid = my_port->pid;
|
||||||
init->read_port.id.id = my_port->id;
|
init->read_port.id.id = my_port->id;
|
||||||
init->read_port.in_fd = my_port->pair[0];
|
init->read_port.in_fd = my_port->pair[0];
|
||||||
init->read_port.out_fd = -1;
|
init->read_port.out_fd = my_port->pair[1];
|
||||||
|
|
||||||
init->log_fd = 2;
|
init->log_fd = 2;
|
||||||
|
|
||||||
|
|||||||
@@ -101,18 +101,24 @@ nxt_external_start(nxt_task_t *task, nxt_process_data_t *data)
|
|||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = nxt_external_fd_no_cloexec(task, my_port->pair[1]);
|
||||||
|
if (nxt_slow_path(rc != NXT_OK)) {
|
||||||
|
return NXT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
end = buf + sizeof(buf);
|
end = buf + sizeof(buf);
|
||||||
|
|
||||||
p = nxt_sprintf(buf, end,
|
p = nxt_sprintf(buf, end,
|
||||||
"%s;%uD;"
|
"%s;%uD;"
|
||||||
"%PI,%ud,%d;"
|
"%PI,%ud,%d;"
|
||||||
"%PI,%ud,%d;"
|
"%PI,%ud,%d;"
|
||||||
"%PI,%ud,%d;"
|
"%PI,%ud,%d,%d;"
|
||||||
"%d,%z,%Z",
|
"%d,%z,%Z",
|
||||||
NXT_VERSION, my_port->process->stream,
|
NXT_VERSION, my_port->process->stream,
|
||||||
main_port->pid, main_port->id, main_port->pair[1],
|
main_port->pid, main_port->id, main_port->pair[1],
|
||||||
router_port->pid, router_port->id, router_port->pair[1],
|
router_port->pid, router_port->id, router_port->pair[1],
|
||||||
my_port->pid, my_port->id, my_port->pair[0],
|
my_port->pid, my_port->id, my_port->pair[0],
|
||||||
|
my_port->pair[1],
|
||||||
2, conf->shm_limit);
|
2, conf->shm_limit);
|
||||||
|
|
||||||
if (nxt_slow_path(p == end)) {
|
if (nxt_slow_path(p == end)) {
|
||||||
|
|||||||
@@ -248,8 +248,6 @@ nxt_process_setup(nxt_task_t *task, nxt_process_t *process)
|
|||||||
|
|
||||||
port = nxt_process_port_first(process);
|
port = nxt_process_port_first(process);
|
||||||
|
|
||||||
nxt_port_write_close(port);
|
|
||||||
|
|
||||||
nxt_port_enable(task, port, init->port_handlers);
|
nxt_port_enable(task, port, init->port_handlers);
|
||||||
|
|
||||||
ret = init->setup(task, process);
|
ret = init->setup(task, process);
|
||||||
@@ -272,6 +270,9 @@ nxt_process_setup(nxt_task_t *task, nxt_process_t *process)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = init->start(task, &process->data);
|
ret = init->start(task, &process->data);
|
||||||
|
|
||||||
|
nxt_port_write_close(port);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ nxt_unit_read_env(nxt_unit_port_t *ready_port, nxt_unit_port_t *router_port,
|
|||||||
uint32_t *shm_limit)
|
uint32_t *shm_limit)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int ready_fd, router_fd, read_fd;
|
int ready_fd, router_fd, read_in_fd, read_out_fd;
|
||||||
char *unit_init, *version_end;
|
char *unit_init, *version_end;
|
||||||
long version_length;
|
long version_length;
|
||||||
int64_t ready_pid, router_pid, read_pid;
|
int64_t ready_pid, router_pid, read_pid;
|
||||||
@@ -812,15 +812,15 @@ nxt_unit_read_env(nxt_unit_port_t *ready_port, nxt_unit_port_t *router_port,
|
|||||||
"%"PRIu32";"
|
"%"PRIu32";"
|
||||||
"%"PRId64",%"PRIu32",%d;"
|
"%"PRId64",%"PRIu32",%d;"
|
||||||
"%"PRId64",%"PRIu32",%d;"
|
"%"PRId64",%"PRIu32",%d;"
|
||||||
"%"PRId64",%"PRIu32",%d;"
|
"%"PRId64",%"PRIu32",%d,%d;"
|
||||||
"%d,%"PRIu32,
|
"%d,%"PRIu32,
|
||||||
&ready_stream,
|
&ready_stream,
|
||||||
&ready_pid, &ready_id, &ready_fd,
|
&ready_pid, &ready_id, &ready_fd,
|
||||||
&router_pid, &router_id, &router_fd,
|
&router_pid, &router_id, &router_fd,
|
||||||
&read_pid, &read_id, &read_fd,
|
&read_pid, &read_id, &read_in_fd, &read_out_fd,
|
||||||
log_fd, shm_limit);
|
log_fd, shm_limit);
|
||||||
|
|
||||||
if (nxt_slow_path(rc != 12)) {
|
if (nxt_slow_path(rc != 13)) {
|
||||||
nxt_unit_alert(NULL, "failed to scan variables: %d", rc);
|
nxt_unit_alert(NULL, "failed to scan variables: %d", rc);
|
||||||
|
|
||||||
return NXT_UNIT_ERROR;
|
return NXT_UNIT_ERROR;
|
||||||
@@ -840,8 +840,8 @@ nxt_unit_read_env(nxt_unit_port_t *ready_port, nxt_unit_port_t *router_port,
|
|||||||
|
|
||||||
nxt_unit_port_id_init(&read_port->id, (pid_t) read_pid, read_id);
|
nxt_unit_port_id_init(&read_port->id, (pid_t) read_pid, read_id);
|
||||||
|
|
||||||
read_port->in_fd = read_fd;
|
read_port->in_fd = read_in_fd;
|
||||||
read_port->out_fd = -1;
|
read_port->out_fd = read_out_fd;
|
||||||
read_port->data = NULL;
|
read_port->data = NULL;
|
||||||
|
|
||||||
*stream = ready_stream;
|
*stream = ready_stream;
|
||||||
|
|||||||
Reference in New Issue
Block a user