nxt_runtime.c (239:efe28cb74427) nxt_runtime.c (240:36bafba970b5)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>
9#include <nxt_runtime.h>
10#include <nxt_port.h>
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>
9#include <nxt_runtime.h>
10#include <nxt_port.h>
11#include <nxt_master_process.h>
11#include <nxt_main_process.h>
12#include <nxt_router.h>
13
14
15static nxt_int_t nxt_runtime_inherited_listen_sockets(nxt_task_t *task,
16 nxt_runtime_t *rt);
17static nxt_int_t nxt_runtime_systemd_listen_sockets(nxt_task_t *task,
18 nxt_runtime_t *rt);
19static nxt_int_t nxt_runtime_event_engines(nxt_task_t *task, nxt_runtime_t *rt);

--- 259 unchanged lines hidden (view full) ---

279 interface = nxt_service_get(rt->services, "engine", NULL);
280
281 if (nxt_slow_path(interface == NULL)) {
282 /* TODO: log */
283 return NXT_ERROR;
284 }
285
286 engine = nxt_event_engine_create(task, interface,
12#include <nxt_router.h>
13
14
15static nxt_int_t nxt_runtime_inherited_listen_sockets(nxt_task_t *task,
16 nxt_runtime_t *rt);
17static nxt_int_t nxt_runtime_systemd_listen_sockets(nxt_task_t *task,
18 nxt_runtime_t *rt);
19static nxt_int_t nxt_runtime_event_engines(nxt_task_t *task, nxt_runtime_t *rt);

--- 259 unchanged lines hidden (view full) ---

279 interface = nxt_service_get(rt->services, "engine", NULL);
280
281 if (nxt_slow_path(interface == NULL)) {
282 /* TODO: log */
283 return NXT_ERROR;
284 }
285
286 engine = nxt_event_engine_create(task, interface,
287 nxt_master_process_signals, 0, 0);
287 nxt_main_process_signals, 0, 0);
288
289 if (nxt_slow_path(engine == NULL)) {
290 return NXT_ERROR;
291 }
292
293 thread = task->thread;
294 thread->engine = engine;
295 thread->fiber = &engine->fibers->fiber;

--- 107 unchanged lines hidden (view full) ---

403 }
404
405 if (nxt_runtime_event_engine_change(task, rt) != NXT_OK) {
406 goto fail;
407 }
408
409 thr->engine->max_connections = rt->engine_connections;
410
288
289 if (nxt_slow_path(engine == NULL)) {
290 return NXT_ERROR;
291 }
292
293 thread = task->thread;
294 thread->engine = engine;
295 thread->fiber = &engine->fibers->fiber;

--- 107 unchanged lines hidden (view full) ---

403 }
404
405 if (nxt_runtime_event_engine_change(task, rt) != NXT_OK) {
406 goto fail;
407 }
408
409 thr->engine->max_connections = rt->engine_connections;
410
411 if (rt->master_process) {
412 if (nxt_master_process_start(thr, task, rt) != NXT_ERROR) {
411 if (rt->main_process) {
412 if (nxt_main_process_start(thr, task, rt) != NXT_ERROR) {
413 return;
414 }
415
416 } else {
417 nxt_single_process_start(thr, task, rt);
418 return;
419 }
420

--- 41 unchanged lines hidden (view full) ---

462 if (!engine->shutdown) {
463 engine->shutdown = 1;
464
465 if (!nxt_array_is_empty(rt->thread_pools)) {
466 nxt_runtime_thread_pool_destroy(task, rt, nxt_runtime_quit);
467 done = 0;
468 }
469
413 return;
414 }
415
416 } else {
417 nxt_single_process_start(thr, task, rt);
418 return;
419 }
420

--- 41 unchanged lines hidden (view full) ---

462 if (!engine->shutdown) {
463 engine->shutdown = 1;
464
465 if (!nxt_array_is_empty(rt->thread_pools)) {
466 nxt_runtime_thread_pool_destroy(task, rt, nxt_runtime_quit);
467 done = 0;
468 }
469
470 if (nxt_runtime_is_master(rt)) {
471 nxt_master_stop_worker_processes(task, rt);
470 if (nxt_runtime_is_main(rt)) {
471 nxt_main_stop_worker_processes(task, rt);
472 done = 0;
473 }
474 }
475
476 nxt_runtime_close_idle_connections(engine);
477
478 if (done) {
479 nxt_work_queue_add(&engine->fast_work_queue, nxt_runtime_exit,

--- 39 unchanged lines hidden (view full) ---

519 engine = data;
520
521 nxt_debug(task, "thread pools: %d", rt->thread_pools->nelts);
522
523 if (!nxt_array_is_empty(rt->thread_pools)) {
524 return;
525 }
526
472 done = 0;
473 }
474 }
475
476 nxt_runtime_close_idle_connections(engine);
477
478 if (done) {
479 nxt_work_queue_add(&engine->fast_work_queue, nxt_runtime_exit,

--- 39 unchanged lines hidden (view full) ---

519 engine = data;
520
521 nxt_debug(task, "thread pools: %d", rt->thread_pools->nelts);
522
523 if (!nxt_array_is_empty(rt->thread_pools)) {
524 return;
525 }
526
527 if (nxt_runtime_is_master(rt)) {
527 if (nxt_runtime_is_main(rt)) {
528 if (rt->pid_file != NULL) {
529 nxt_file_delete(rt->pid_file);
530 }
531
532#if (NXT_HAVE_UNIX_DOMAIN)
533 {
534 nxt_sockaddr_t *sa;
535 nxt_file_name_t *name;

--- 171 unchanged lines hidden (view full) ---

707 nxt_int_t ret;
708 nxt_file_t *file;
709 nxt_str_t control;
710 nxt_sockaddr_t *sa;
711 nxt_file_name_str_t file_name;
712 const nxt_event_interface_t *interface;
713
714 rt->daemon = 1;
528 if (rt->pid_file != NULL) {
529 nxt_file_delete(rt->pid_file);
530 }
531
532#if (NXT_HAVE_UNIX_DOMAIN)
533 {
534 nxt_sockaddr_t *sa;
535 nxt_file_name_t *name;

--- 171 unchanged lines hidden (view full) ---

707 nxt_int_t ret;
708 nxt_file_t *file;
709 nxt_str_t control;
710 nxt_sockaddr_t *sa;
711 nxt_file_name_str_t file_name;
712 const nxt_event_interface_t *interface;
713
714 rt->daemon = 1;
715 rt->master_process = 1;
715 rt->main_process = 1;
716 rt->engine_connections = 256;
717 rt->auxiliary_threads = 2;
718 rt->user_cred.user = NXT_USER;
719 rt->group = NXT_GROUP;
720 rt->pid = NXT_PID;
721 rt->log = NXT_LOG;
722 rt->modules = NXT_MODULES;
723 rt->control = NXT_CONTROL_SOCK;

--- 1097 unchanged lines hidden ---
716 rt->engine_connections = 256;
717 rt->auxiliary_threads = 2;
718 rt->user_cred.user = NXT_USER;
719 rt->group = NXT_GROUP;
720 rt->pid = NXT_PID;
721 rt->log = NXT_LOG;
722 rt->modules = NXT_MODULES;
723 rt->control = NXT_CONTROL_SOCK;

--- 1097 unchanged lines hidden ---