Removing Unix control socket on start failure.

The bug had appeared in 5cc5002a788e when process type has been
converted to bitmask. This commit reverts the type back to a number.

This commit is related to #131 issue on GitHub.
This commit is contained in:
Igor Sysoev
2018-06-18 17:14:30 +03:00
parent 6273819080
commit cb36b07686
5 changed files with 5 additions and 23 deletions

View File

@@ -80,7 +80,7 @@ nxt_int_t
nxt_main_process_start(nxt_thread_t *thr, nxt_task_t *task, nxt_main_process_start(nxt_thread_t *thr, nxt_task_t *task,
nxt_runtime_t *rt) nxt_runtime_t *rt)
{ {
rt->types |= (1U << NXT_PROCESS_MAIN); rt->type = NXT_PROCESS_MAIN;
if (nxt_main_process_port_create(task, rt) != NXT_OK) { if (nxt_main_process_port_create(task, rt) != NXT_OK) {
return NXT_ERROR; return NXT_ERROR;

View File

@@ -306,8 +306,6 @@ nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
rt = task->thread->runtime; rt = task->thread->runtime;
nxt_assert(nxt_runtime_is_main(rt));
process = nxt_runtime_process_find(rt, msg->port_msg.pid); process = nxt_runtime_process_find(rt, msg->port_msg.pid);
if (nxt_slow_path(process == NULL)) { if (nxt_slow_path(process == NULL)) {
return; return;

View File

@@ -62,8 +62,6 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
process->pid = nxt_pid; process->pid = nxt_pid;
rt->types = 0;
ptype = process->init->type; ptype = process->init->type;
nxt_port_reset_next_id(); nxt_port_reset_next_id();
@@ -149,7 +147,7 @@ nxt_process_start(nxt_task_t *task, nxt_process_t *process)
rt = thread->runtime; rt = thread->runtime;
rt->types |= (1U << init->type); rt->type = init->type;
engine = thread->engine; engine = thread->engine;

View File

@@ -433,7 +433,7 @@ nxt_runtime_quit(nxt_task_t *task)
done = 0; done = 0;
} }
if (nxt_runtime_is_main(rt)) { if (rt->type == NXT_PROCESS_MAIN) {
nxt_main_stop_worker_processes(task, rt); nxt_main_stop_worker_processes(task, rt);
done = 0; done = 0;
} }
@@ -490,7 +490,7 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data)
return; return;
} }
if (nxt_runtime_is_main(rt)) { if (rt->type == NXT_PROCESS_MAIN) {
if (rt->pid_file != NULL) { if (rt->pid_file != NULL) {
nxt_file_delete(rt->pid_file); nxt_file_delete(rt->pid_file);
} }

View File

@@ -43,7 +43,7 @@ struct nxt_runtime_s {
uint32_t last_engine_id; uint32_t last_engine_id;
uint32_t types; /* bitset of nxt_process_type_t */ nxt_process_type_t type;
nxt_timer_t timer; nxt_timer_t timer;
@@ -83,20 +83,6 @@ nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt,
nxt_uint_t max_threads, nxt_nsec_t timeout); nxt_uint_t max_threads, nxt_nsec_t timeout);
nxt_inline nxt_bool_t
nxt_runtime_is_type(nxt_runtime_t *rt, nxt_process_type_t type)
{
return (rt->types & (1U << type)) != 0;
}
nxt_inline nxt_bool_t
nxt_runtime_is_main(nxt_runtime_t *rt)
{
return nxt_runtime_is_type(rt, NXT_PROCESS_MAIN);
}
nxt_process_t *nxt_runtime_process_new(nxt_runtime_t *rt); nxt_process_t *nxt_runtime_process_new(nxt_runtime_t *rt);
nxt_process_t *nxt_runtime_process_get(nxt_runtime_t *rt, nxt_pid_t pid); nxt_process_t *nxt_runtime_process_get(nxt_runtime_t *rt, nxt_pid_t pid);